简体   繁体   中英

Calculated measures in MDX not working

I wanted to have results something like this:

city zip revenue x

A | 1 | 2000 | 10000

A | 2 | 3000 | 10000

A | 3 | 5000 | 10000

B | 6 | 1500 | 3000

B | 9 | 1500 | 3000

To get the results, I wrote this mdx statement, but revenue and X are coming out same. I thought the revenue would be aggregated over city only and for each zip the value would be the same because the city associated with the zip is same. I wonder if any body can help me out here.

with member [Measures].[X] as '([Location].[City].currentmember, [Measures].[Revenue])'

SELECT NON EMPTY { Measures.[Revenue], [Measures].[X]} ON COLUMNS, NON EMPTY { ([Location].[City].[City]*[Location].[zip].[zip] ) } ON ROWS FROM [State Revenue]))

Regards

You have to specify explicitly that you need the aggregated total for the zip code. Try adding the DefaultMember of the [zip] hierarchy in the tuple, as follows:

with member [Measures].[X] as '([Location].[City].currentmember, [Location].[Zip].DefaultMember, [Measures].[Revenue])'

SELECT NON EMPTY { Measures.[Revenue], [Measures].[X]} ON COLUMNS, NON EMPTY { ([Location].[City].[City]*[Location].[zip].[zip] ) } ON ROWS FROM [State Revenue]))

The DefaultMember function represents the (All) member unless specified otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM