[Mondrian] [MDX] How to find the current hierarchy

Julian Hyde jhyde at pentaho.com
Thu Dec 22 14:29:47 EST 2011

On Dec 22, 2011, at 10:51 AM, Pedro Alves wrote:

> That's exactly what I want. On this case I'm interested in defining a 
> measure that says the percentage of that element according to the 
> total. I guess I'll have to rethink this, thanks

An idea. One could write a UDF that finds which hierarchies are displayed on some axis of the current query. "DisplayedHierarchy(Dimension)" might return the displayed hierarchy if precisely one hierarchy is on an axis; otherwise return the first hierarchy of the dimension.

I don't usually like functions like this. Like VisualTotals, it is "impure": it breaks the principle that a value depends only on the dimensional context.

The other way of looking at it is: Why are you using dimensions? Dimensions are little more than groupings of hierarchies, so you should use them for bucketing them in the UI, but not for very much else.


More information about the Mondrian mailing list