Add element to subset based on MDX Results attribute

Post Reply
Bakkone
Posts: 119
Joined: Mon Oct 27, 2014 10:50 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Add element to subset based on MDX Results attribute

Post by Bakkone »

Sorry about the confusing title.

The MDX code:
{FILTER( {TM1SUBSETALL( [Version] ) }, [Version].[ isCurrentForecast]= 1)}

Returns a single element member (But in theory could return several I guess). Lets call it [FC2]. [FC2] has an attribute called PrevFC. The value of this attribute is "FC1", which is also an element in the dimension.

What I would want is the query to return both [FC1] and [FC2] in the subset. Any ideas on how to do this?
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Add element to subset based on MDX Results attribute

Post by declanr »

Code: Select all

{UNION(
	{FILTER({[version].members},[version].[IsCurrentForecast]=1)},
	{GENERATE(
		{FILTER({[version].members},[version].[IsCurrentForecast]=1)},
		{StrToMember( "[version].[" + [version].[PrevFC] + "]" )}
	)}
)}
The above will work as long as the "PrevFC" is always populated for every version; if there is a chance it won't be then you can add a check in to ignore it if not.
The generate is required because as you mentioned the "IsCurrentForecast" could theoretically return more than 1 element... if you do genuinely have only 1 current forecast at any one point then I would hold it in a control cube and just wrap a StrToMember around that value as a starting point instead. This should be a good starting point for you though and you can extrapolate it as you require.
Declan Rodger
Bakkone
Posts: 119
Joined: Mon Oct 27, 2014 10:50 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Add element to subset based on MDX Results attribute

Post by Bakkone »

Thanks for the help! Works like a charm.

I really need to find a day or so to play around with MDX.
Post Reply