1
votes

Environment: SSAS v12.

Why the following function

DESCENDANTS([Dim1].[Hier1].[(All)])

returns only [Dim1].[Hier1].[(All)] ?

Expectation is to return the root member and all it's descendants.

Or how to achieve that?

PS Specifying [ , Level_Expression [ ,Desc_Flag ] ] does not help...

Many thanks in advance.

2

2 Answers

0
votes

You can specify how far down you want to go, whether it's to a specific level or to the leaves:

DESCENDANTS([Dim1].[Hier1].CurrentMember, [Dim1].[Hier1].[Hier1], LEAVES)
0
votes

You can try adding one of the flags:

DESCENDANTS(
    [Dim1].[Hier1].[All]   //<<member
  , [Dim1].[Hier1].[(All)] //<<level
  , SELF_BEFORE_AFTER      //<<flag
)

Documentation of the function is here: https://docs.microsoft.com/en-us/sql/mdx/descendants-mdx

The documentation gives a way of experimenting with the different flags:

SELECT Descendants  
   ([Geography].[Geography].[Country].&[United States]  
      //, [Geography].[Geography].[Country]  
   , [Geography].[Geography].[City]  
      //, [Geography].[Geography].Levels (3)  
      //, SELF   
      //, AFTER  
      , BEFORE  
      // BEFORE_AND_AFTER  
      //, SELF_AND_AFTER  
      //, SELF_AND_BEFORE  
      //,SELF_BEFORE_AFTER  
      //,LEAVES   
   ) ON 0  
FROM [Adventure Works]