MDX Expression needed

Post Reply
SBK88
Posts: 45
Joined: Fri Apr 17, 2015 5:55 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2013

MDX Expression needed

Post by SBK88 »

I have 5 Elements A, B, C, D, E ( all are of level 4-5..... they have hierarchy of their own).... Dimension Name : PRODUCT
C is Child of B

I am looking for an MDX Expression to display A, B, C and all only Leaf level Elements of C

Need Help
Wim Gielis
MVP
Posts: 3113
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: MDX Expression needed

Post by Wim Gielis »

Code: Select all

{[PRODUCT].[A]} + {[PRODUCT].[B]} + {[PRODUCT].[C]} + {TM1FilterByLevel( Descendants([PRODUCT].[C]), 0)}
Best regards,

Wim Gielis

IBM Champion 2024
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
User avatar
gtonkin
MVP
Posts: 1198
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: MDX Expression needed

Post by gtonkin »

Apologies OP for high-jacking the thread to some degree but was intrigued with Wim's notation using the plus sign to "add" elements to the set.
I have always just done:

Code: Select all

{[PRODUCT].[A], [PRODUCT].[B], [PRODUCT].[C], TM1FilterByLevel( Descendants([PRODUCT].[C]), 0)}
but like the plus signs for readability-Thanks Wim.
Last edited by gtonkin on Fri May 12, 2017 4:23 pm, edited 2 times in total.
lotsaram
MVP
Posts: 3652
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: MDX Expression needed

Post by lotsaram »

gtonkin wrote:Apologies OP for higj-jacking the thread to some degree but was intrigued with Wim's notation using the plus sign to "add" elements to the set.
I have always just done:

Code: Select all

{[PRODUCT].[A], [PRODUCT].[B], [PRODUCT].[C], TM1FilterByLevel( Descendants([PRODUCT].[C]), 0)}
but like the plus signs for readability-Thanks Wim.
In MDX "+" is shorthand for UNION
e.g.
{set1} + {set2}
=
{UNION( {set1}, {set2} )}

A union will automatically remove duplicates from the sets, whereas the comma operator simply concatenates the sets together (without removing duplicates). You can show this pretty simply by comparing
{ {set1}, {set1} }
vs.
{ {set1} + {set1} }
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
User avatar
gtonkin
MVP
Posts: 1198
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: MDX Expression needed

Post by gtonkin »

Thanks for the clarification Lotsa-will keep that in mind.
Wim Gielis
MVP
Posts: 3113
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: MDX Expression needed

Post by Wim Gielis »

Indeed, we have UNION( ), we have a comma and we have the + operator.
They differ when it comes to duplicate elements in the selection.
Best regards,

Wim Gielis

IBM Champion 2024
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
SBK88
Posts: 45
Joined: Fri Apr 17, 2015 5:55 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2013

Re: MDX Expression needed

Post by SBK88 »

Yes UNION worked for me......
Created 2 separate expressions then used UNION and it worked.

Thanks to all of u
User avatar
yyi
Community Contributor
Posts: 121
Joined: Thu Aug 28, 2008 4:42 am
Location: Sydney, Australia

Re: MDX Expression needed

Post by yyi »

Code: Select all

{[PRODUCT].[A]} + {[PRODUCT].[B]} + {[PRODUCT].[C]} + {TM1FilterByLevel( Descendants([PRODUCT].[B^C]), 0)}
just while I was refreshing the browser anxiously to see if anyone answered the question in my post (does anyone else do this I wonder..); I thought I'd add an idea to this thread - if there are any alternate hierarchy used in product dim, then it may be necessary to explicitly state the rollup name where the descendants come from [B1 or B2 being Parent1 or Parent2].
Yeon
Post Reply