Page 1 of 1

Add element to subset based on MDX Results attribute

Posted: Sun Oct 30, 2016 1:54 pm
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?

Re: Add element to subset based on MDX Results attribute

Posted: Sun Oct 30, 2016 2:32 pm
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.

Re: Add element to subset based on MDX Results attribute

Posted: Tue Nov 01, 2016 12:31 pm
by Bakkone
Thanks for the help! Works like a charm.

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