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