2
votes

When I run this mdx query, works fine (get the children members from a hierarchy level):

select {} on columns,
[Dimension].[hierarchy].[level].children on rows
from [Cube]

But, when I add some tuple on rows, doesn't filter filter the children members (shows all the members) :S

select {} on columns,
[Dimension].[hierarchy].[level].children 
* [Dimension2].[hierarchy2].[level2].allmembers on rows
from [Cube]
3
I don't understand your first script - this is not a valid construction [Dimension].[hierarchy].[level].children as the function children cannot be applied to [Level] - it can only be applied to a [Member] .... is it definitely a level in your first script ?whytheq

3 Answers

1
votes

* is a cross join - you will get the Cartesian product of [Dimension].[hierarchy].[level].children and [Dimension2].[hierarchy2].[level2].allmembers because they are different dimensions.

If they were two hierarchies from the same dimension then auto exist behaviour would limit the results e.g. Year2014 crossed with month should just show the months in 2014.

Try using DESCENDANTS function + you might not require NULLs so try the NON EMPTY

SELECT
  {} ON COLUMNS,
  NON EMPTY
  DESCENDANTS(
    [Dimension].[hierarchy].[level].[PickAHigherUpMember],
    [Dimension].[hierarchy].[PickTheLevelYouWantToDrillTo]
    ) 
  * 
  [Dimension2].[hierarchy2].[level2].allmembers ON ROWS
FROM [Cube]
0
votes

if you look at the mdx language reference for children, you will also find another example of how to use the function with a hierarchy in stead of a member_expression.

http://msdn.microsoft.com/en-us/library/ms146018.aspx

but it won't work with a hierarchy level.

Maybe the row expression was initialy a hierarchy that you've have changed into a level expression.

in the following a similar working mdx with a hierarchy on rows:

select {} on 0,
[Product].[Model Name].children
*
[Geography].[Country].[All Geographies]
 on 1
FROM [Adventure Works

Philip,

0
votes

I guess you want only those rows where the children have a value on the default measure. In that case you could try the following:

select {} on columns,
Nonempty([Dimension].[hierarchy].[level].children 
* [Dimension2].[hierarchy2].[level2].allmembers) on rows
from [Cube]

Now if, for the children, you'd need all the members from Dimension2 then you could try:

select {} on columns,
Nonempty([Dimension].[hierarchy].[level].children, [Dimension2].[hierarchy2].[level2].allmembers)
* [Dimension2].[hierarchy2].[level2].allmembers) on rows
from [Cube]

In the second case the Nonempty function takes a second parameter and the cross join is done with the result of the Nonempty function. For the documentation on Nonempty including the usage of the second parameter see https://docs.microsoft.com/en-us/sql/mdx/nonempty-mdx