Search code examples
mdxolapmondrian

Mondrian - why do I need explicit level to reference a member in a hierarchy?


If I want to reference a member in a hierarchy in a Mondrian MDX query (using Mondrian 4.4), I have to reference the level explicitly in the expression. For example, in SSAS I can do something like

[Customer].[Customer Geography].[Canada]

but in Mondrian I have to add the name of the first hierarchy level explicitly

[Customer].[Customer Geography].[Country-Region].[Canada]

Where should I be looking to troubleshoot? My hierarchy is simple, with only two levels and hasAll="false".


Solution

  • In SSAS when you write this [Customer].[Customer Geography].[Canada] I believe that it is short-hand for this:

    [Customer].[Customer Geography].[All].[Canada]
    

    These two scripts give the same result:

    SELECT 
      [Customer].[Customer Geography].[All].[Canada] ON 0
    FROM [Adventure Works];
    
    SELECT 
      [Customer].[Customer Geography].[Canada] ON 0
    FROM [Adventure Works];
    

    So if your hierarchy has no [All] member the members will be children of the highest level. I think SSAS will assume the highest level even if you do not explicitly state it but it looks like mondrian needs it explicitly adding in to your mdx.