MDX - return all root elements

Post Reply
andreask
Posts: 4
Joined: Wed Feb 16, 2011 9:42 am
OLAP Product: TM1
Version: 9.5.1
Excel Version: 2007

MDX - return all root elements

Post by andreask »

I was just wondering if there's any possiblity to get all root elements?

.members gives me the complete hierarchy back and with filebylevel I need to know the exact level - which can change.

Any other ideas?
lotsaram
MVP
Posts: 3701
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: MDX - return all root elements

Post by lotsaram »

You need to be clear on what exactly you mean by "all root elements". Do you mean ...
- All elements in the dimension? (TM1SubsetAll function)
- All leaf elements? (Nest TM1FilterByLevel with TM1SubsetAll)
- All "root hierarchy" nodes? (that is members with descendants but no ancestors, MDX is more tricky but can also be done.)
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

Doesn't filtering for all level 0 give all root elements???
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
lotsaram
MVP
Posts: 3701
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: MDX - return all root elements

Post by lotsaram »

Like I said, depends what the OP meant by root element.
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

Indeed.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: MDX - return all root elements

Post by rmackenzie »

andreask wrote:I was just wondering if there's any possiblity to get all root elements?
lotsaram wrote:- All "root hierarchy" nodes? (that is members with descendants but no ancestors, MDX is more tricky but can also be done.)
My read on the OP's question is that he wants all the top-level consolidations:

Code: Select all

{Filter(
  {TM1SubsetAll([YOUR_DIMENSION_NAME])}, 
  [YOUR_DIMENSION_NAME].CurrentMember.Parent.Name="")
}
Robin
Robin Mackenzie
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

That's very different from most peoples definition of root members??
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: MDX - return all root elements

Post by rmackenzie »

Jim, interesting... I guess the 'root' is sort of the opposite of the 'leaf' (n-level) if we are talking tree analogies... so I often refer to the top consolidations as root elements.
Robin Mackenzie
User avatar
Martin Ryan
Site Admin
Posts: 1989
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: MDX - return all root elements

Post by Martin Ryan »

For what it's worth, if you add in an element into the Dimension Editor with no parent (i.e. top level) then the little dialog box calls the parent "Root"
toplevel.JPG
toplevel.JPG (25.69 KiB) Viewed 13455 times
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

Martin,

If it has no parent it is the bottom level as well,

Jim.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
User avatar
Martin Ryan
Site Admin
Posts: 1989
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: MDX - return all root elements

Post by Martin Ryan »

Yabbut, if it gets children its parent will still be "Root".
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

Will it though? By putting Root in parent it is actually suggesting it has no parent as it is a root object. This a dialogue box for adding elements. If you insert a child to this it will say the element you first created as a parent. How ever if you select add element instead of insert child the parent will say root. You could argue it's right in both cases. When an element has no parent and is level 0. If it has no parent and is level 6 it is still root, therefore root is neither level 0 or level6, it is any element that has no parent. If we are holding with this definition that is.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: MDX - return all root elements

Post by rmackenzie »

jim wood wrote:When an element has no parent and is level 0. If it has no parent and is level 6 it is still root, therefore root is neither level 0 or level6, it is any element that has no parent. If we are holding with this definition that is.
Generally, my definition of root element is any consolidation at the top of the hierarchy. I agree, technically speaking, that an orphan n-level is still a root element; and will be picked up by the MDX query I posted above.

The flip-side of this point can be seen when using the following well-known MDX which returns all 0-level elements. As well as all the n-level elements (which is what people generally want) this will also return consolidated elements that have no children:

Code: Select all

{TM1FilterByLevel({TM1SubsetAll([YOUR_DIMENSION_NAME])}, 0)}
One challenge that has always puzzled me is how to exclude the c-level elements from this query (without using attributes). In other words, how is it possible to get the same functionality as DTYPE, but in an MDX statement?

I think this conversation just goes to show the subtle differences between the level of an element in a dimension and the definition of n- and c-level elements.
Robin Mackenzie
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: MDX - return all root elements

Post by tomok »

rmackenzie wrote:Generally, my definition of root element is any consolidation at the top of the hierarchy. I agree, technically speaking, that an orphan n-level is still a root element; and will be picked up by the MDX query I posted above.
In TM1, a root element is any element that doesn't have a parent. It can be either a bottom level element or a consolidation.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: MDX - return all root elements

Post by jim wood »

So you agree with me then Tomok?
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
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 - return all root elements

Post by Michel Zijlema »

jim wood wrote:So you agree with me then Tomok?
Hi Jim,

I thought that the root of something that is not branching out should be called a carrot :?

Michel
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: MDX - return all root elements

Post by tomok »

jim wood wrote:So you agree with me then Tomok?
Yes. I was just boiling down the facts to a simple concise statement.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Post Reply