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!
In SQL the SELECT list is derived from tables and the FROM clause is also directly on tables. On the other hand in MDX the SELECT list derived from dimensions but unlike SQL the FROM clause is always on the cube not on dimensions.
As a result MDX requires that you always explicitly specify a display axis for all elements in the SELECT list. In SQL if you select from two or more tables you have to explicitly join the tables with a “JOIN” word.
Another thing to note is that, I derived the first Sales Territory set from attribute hierarchies and the second set from user-defined hierarchy in the Sales Territory dimension. This is because MDX expects the sets you are cross joining to always come from different hierarchies. You can cross join multiple set by nesting cross joins as below.
In listing8 below, the two tuples on ROWS in MDX1 has the same number and ordering of the dimension members. On the other hand the number of dimension members in the two tuples on the ROWS axis in MDX2 does not conform. The second tuple has only two dimension members as oppose to three in the first tuple so it fails when you execute it. Listing8.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With