I have the following data structure
age range sex population_segment
1 0-4 1 100
2 0-4 1 100
3 0-4 1 100
4 0-4 1 100
5 5-9 1 150
6 5-9 1 150
I want to get running sum based at the only first range and sex attributes change in the set. For example, correct answer for me is to summarize only record 1 and record 5 (i.e. 250). My groupers are range and sex.
Currently my measure is just summing all values, getting me the wrong sum of population: 750 I know how to do it in standard SQL (posted here for clarification), but I need MDX solution, calculated member.
Sample sql:
WITH cte AS
(
select
*,
RowNum = row_number() over(partition by range, sex order by range, sex)
FROM myPopulationData
)
SELECT SUM(population_segment) FROM cte WHERE RowNum = 1
This is a case that can be resolved with a many-to-many relationship:
Once you have set up everything, all the calculation logic is handled automatically by Analysis Services.
It is a matter of usability for the users if you leave range and sex in the age dimension in addition to the range-sex dimension and make the range-sex dimension (built from the first table and linked from the bridge table) invisible, or if you keep the age in on and range in another dimension. I personally would prefer the first choice, at least for the range.