Sunday, February 19, 2012

Append two results in MDX

I have a requirement where I need to display the total count of the population by Gender and Race (both dimensions) in one report. The layout will look something similar to …

Count1

Count2

Male

Female

American Indian or Alaska Native

Asian or Pacific Islander

Black, non-Hispanic

Hispanic

White, non-Hispanic

In simple SQL terms this can be achieved by UNION ALL clause,

Select Gender, Count1, Count2…From Table1 Group by Gender

UNION ALL

Select Race, Count1, Count2…From Table1 Group by Race

How can I get similar results in MDX or Reporting Service?

Thanks

In MDX you cannot mix different members in one column, so you would have to end up at a set that looked like the following:

Count1

Count2

Male - All Races

Female - All Races

All Genders - American Indian or Alaska Native

All Genders -Asian or Pacific Islander

All Genders -Black, non-Hispanic

All Genders - Hispanic

All Genders - White, non-Hispanic

Which you would do with a query like:

SELECT {Measures.Count1, Measures.Count2} ON COLUMNS

{

[Gender].[Gender].[Gender].Members * {[Race].[Race].[All] }

,{[Gender].[Gender].[All]} * [Race].[Race].[Race].Members

} ON ROWS

FROM [Cube]

No comments:

Post a Comment