Page 1 of 1

MDX to select top level elements

Posted: Fri Nov 30, 2012 3:01 pm
by holger_b
I am trying to think of an MDX that would give me all the top level elements of a dimension. I saw this discussion http://www.tm1forum.com/viewtopic.php?p=26127 which came to no real conclusion as to my problem. What I have in mind is the following:

{Head ( TM1SubsetAll ( [Clients] ) )} gives me the first top level element, the name of it is "All Client Groups".
{[Clients].[All Client Groups].Siblings} gives me all the elements which I want to see (i.e. all the top level elements and, yes, there are N-elements among them which is okay for me).

Now I tried something like this, but I failed: {[Clients].[{Head ( TM1SubsetAll ( [Clients] ) )}].Siblings}

To be precise: In my mind, top level elements are elements that have no parent. If someone can give me a solution for "Consolidated elements that have no parent" that would be fine as well in this case.

Regards
Holger

Re: MDX to select top level elements

Posted: Fri Nov 30, 2012 3:15 pm
by Michel Zijlema
Hi,

Maybe this is what you're looking for?:

Code: Select all

{FILTER( {TM1SUBSETALL( [Clients] )}, [Clients].CurrentMember.Parent.Name="")}
Michel

EDIT: although I see that one is covered in the thread you referred to

Re: MDX to select top level elements

Posted: Mon Dec 03, 2012 10:46 am
by rozef
Hi holger,

this should work:

{ FILTER(
{TM1SUBSETALL( [MyDim] )},
[MyDim].CurrentMember.Level.ordinal = 0
) }

level.ordinal refer to generation starting by 0.

Re: MDX to select top level elements

Posted: Mon Dec 03, 2012 12:36 pm
by Wim Gielis
Statements like that can be found on this page (direct link to my website):

http://users.skynet.be/fa436118/wim/tm1 ... nts_EN.htm

Re: MDX to select top level elements

Posted: Mon Dec 03, 2012 12:52 pm
by holger_b
Perfect! Thanks to all of you for your quick help.

Best regards
Holger