Search code examples
ssasmdx

How do I determine which Measure the user is using in a PivotTable using MDX?


I have an Account dimension in my cube, and a custom aggregate that takes my CAD measure and divide it depending on what account it is.

Now, I need to add another measure to the cube called USD, and depending on the measure the user is looking at in the pivot table, I need to use either CAD or USD for the Custom rollup calculation.

I'm hoping something like

IIF([Measures].CurrentMember.Name = "CAD", [Measures].[CAD] / xxx, [Measures].[USD] / xxx)

would work, but I haven't tested it yet because I don't know a very good way to debug it without changing my underlying tables and reprocessing the entire cube (which takes quite a while).

The platform I'm using is SSAS 2008R2.

Please give me some pointers for solving this issue. Thanks!

Edit: The MSDN site says:

When a dimension contains only a single visible hierarchy, the hierarchy can be referred to either by the dimension name or by the hierarchy name, because the dimension name is resolved to its only visible hierarchy. For example, Measures.CurrentMember is a valid MDX expression because it resolves to the only hierarchy in the Measures dimension.

I believe then that the expression I gave above will not work, as [Measures] in this case points to the Account dimension hierarchy.


Solution

  • I believe then that the expression I gave above will not work, as [Measures] in this case points to the Account dimension hierarchy.

    Nope : [Measures] is and will always refer to the only [Measures] dimension in your cube.

    If you want to access the current [Account] member, then use [Account].CurrentMember (and add possibly the hierarchy if more than one); but from your question, it is not clear which issue you're trying to solve.