MDX to select top level elements

Post Reply
holger_b
Posts: 131
Joined: Tue May 17, 2011 10:04 am
OLAP Product: TM1
Version: Planning Analytics 2.0
Excel Version: 2016
Location: Freiburg, Germany

MDX to select top level elements

Post 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
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: MDX to select top level elements

Post 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
rozef
Posts: 74
Joined: Thu Jun 17, 2010 10:35 am
OLAP Product: TM1
Version: 9.4 9.5.1
Excel Version: 2003 - 2007

Re: MDX to select top level elements

Post by rozef »

Hi holger,

this should work:

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

level.ordinal refer to generation starting by 0.
Wim Gielis
MVP
Posts: 3229
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: MDX to select top level elements

Post 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
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
holger_b
Posts: 131
Joined: Tue May 17, 2011 10:04 am
OLAP Product: TM1
Version: Planning Analytics 2.0
Excel Version: 2016
Location: Freiburg, Germany

Re: MDX to select top level elements

Post by holger_b »

Perfect! Thanks to all of you for your quick help.

Best regards
Holger
Post Reply