MDX - How to identify empty subset through MDX

Post Reply
lav4you
Posts: 52
Joined: Fri Jan 02, 2009 1:20 pm

MDX - How to identify empty subset through MDX

Post by lav4you »

Hi All,

I would like perform a dynamic operation on a subset such that,

IF FILTER MDX Expression returns empty subset then use different subset else use the same.



Code: Select all

IIF( 
	ISEMTPY(   FILTER(TM1SUBSETALL([Employee]) , [Employee].[State]) = "Active"  ) , 
	[Employee].MEMBER,
	FILTER(TM1SUBSETALL([Employee]) , [Employee].[State]) = "Active"
)
How to achieve this through MDX?? Any thought?
User avatar
gtonkin
MVP
Posts: 1259
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 - How to identify empty subset through MDX

Post by gtonkin »

I am thinking that you may have found a use-case for TM1TupleSize!
BR, George.

Learn something new: MDX Views
Wim Gielis
MVP
Posts: 3230
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 - How to identify empty subset through MDX

Post by Wim Gielis »

Hello,

Here is an example that might guide you in the direction of a solution.

Code: Select all

StrToSet( Iif( Count( Filter( TM1SubsetAll([Company]), [Company].CurrentMember.Properties("Active") = "Y" )) > 0, 
"Filter( TM1SubsetAll( [Company]), [Company].CurrentMember.Properties(""Active"") = ""Y"" )", 
"TM1SubsetAll([Company])" ))
If there are Active companies, filter those out.
If there are No Active companies, return all companies.

The function StrToSet is not my favorite. Working with text to generate an MDX query is second best in my opinion.
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
lav4you
Posts: 52
Joined: Fri Jan 02, 2009 1:20 pm

Re: MDX - How to identify empty subset through MDX

Post by lav4you »

Thanks gtonkin.

Thanks Wim, I have done exactly that IIF and Count.

I got this idea from your website with amazing pool of MDX examples.

Thanks for that..


Regards,
Lav
Wim Gielis
MVP
Posts: 3230
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 - How to identify empty subset through MDX

Post by Wim Gielis »

You’re welcome, glad you have a solution.
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
Post Reply