tags:

views:

972

answers:

1

The relevant structures from my cube are that I have a Hierarchy with "Class" and "SubClass". I also have a Measure called "Value" which is what im trying to obtain.

A simple query may look like:

SELECT
 NON EMPTY ([Measures].[Value]) ON COLUMNS,
 NON EMPTY ([Some Dimension].[Class Hierarchy].[Class]) ON ROWS
FROM [MyCube]

And I can obviously read the SubClass using the HIerarchy which is returned to Adomd.

My issue is twofold, firstly how would I "flatten" this hierarchy so as to receive both Class and SubClass as discrete members in the CellSet? This does not work:

SELECT
 NON EMPTY ([Measures].[Value]) ON COLUMNS,
 NON EMPTY (
   [Some Dimension].[Class Hierarchy].[Class], 
   [Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]

The Class Hierarchy hierarchy is used more than once in the Crossjoin function

Second issue, what I actuually need to do is filter the above on particular classes, again this wont work for the same reason as above.

SELECT
 NON EMPTY ([Measures].[Value]) ON COLUMNS,
 NON EMPTY (
   {[Some Dimension].[Class Hierarchy].[Class].&[ClassA],[Some Dimension].[Class Hierarchy].[Class].&[ClassB]}, 
   [Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]

Any help much appreciated. MDX is driving me nuts!

+1  A: 

You are missing the MEMBERS property on your dimension.

For your first example try this:

SELECT 
    NON EMPTY ([Measures].[Value]) ON COLUMNS,
    NON EMPTY {(
      [Some Dimension].[Class Hierarchy].[Class].MEMBERS,
      [Some Dimension].[Class Hierarchy].[Sub Class].MEMBERS)} ON ROWS
FROM [MyCube]

For your second example try this:

SELECT 
    NON EMPTY ([Measures].[Value]) ON COLUMNS, 
    NON EMPTY {(
      [Some Dimension].[Class Hierarchy].[Class].&[ClassA],
      [Some Dimension].[Class Hierarchy].[Class].&[ClassB],
      [Some Dimension].[Class Hierarchy].[Sub Class].MEMBERS)} ON ROWS
FROM [MyCube]
TskTsk
Thanks for the answer, but im afraid its wrong. This produuces the same error "The Class Hierarchy hierarchy is used more than once in the Crossjoin function"
Jamiec
Sorry. It works just fine on my cube. Double check that you have the curly braces and parenthesis in the right spots. I'm a bit confused that you talk about a crossjoin function but it's not in your sample MDX. Typically it's denoted by the * between dimensions.
TskTsk
Jamiec
I see what you mean. I was using the attribute hierarchies directly instead of hierarchies. That's what the above will work with. I think cross joins across used defined hierarchies aren't supported.
TskTsk
That should say user defined hierarchies instead of used...
TskTsk
Thanks for the info and your help with the question.
Jamiec