Hi,
I am trying to create dynamic subset using below MDX,but it is not working.
Need suggestions on this.
SubsetCreateByMDX('WaferSize_Item',ELPAR('Product_Dim','{FILTER( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Product_Dim] )}, 0)}, [Product_Dim].[SIZE] = "200")}'), 1));
Here "200" is Attribute value of products and wants replace with user input variable.
Regards,
Sathish
Dynamic Subset using MDX
-
- Posts: 38
- Joined: Mon Dec 20, 2010 5:02 am
- OLAP Product: Cognos TM1
- Version: 9.4 and 9.5
- Excel Version: 2003 and 2007
-
- 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: Dynamic Subset using MDX
The ELPAR section of your code isn't MDX and the subsetcreatebymdx function only accepts an mdx statement so that won't work. I can't remember off the top of my head how you get element parents in MDX but the following should work.sathishh.mk wrote:Hi,
I am trying to create dynamic subset using below MDX,but it is not working.
Need suggestions on this.
SubsetCreateByMDX('WaferSize_Item',ELPAR('Product_Dim','{FILTER( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Product_Dim] )}, 0)}, [Product_Dim].[SIZE] = "200")}'), 1));
Here "200" is Attribute value of products and wants replace with user input variable.
Regards,
Sathish
Code: Select all
SubsetCreateByMDX ( 'WaferSize_Item_temp', sMDX, sDimName );
SubsetCreate ( sDimName, 'WaferSize_Item' );
iCount = 1;
iMax = SubsetGetSize ( sDimName, 'WaferSize_Item_Temp' );
While ( iCount <= iMax );
sElement = SubsetGetElementName ( sDimName, 'WaferSize_Item_Temp', iCount );
sParent = ElPar ( sDimName, sElement, 1 );
If ( sParent @<> '' );
SubsetElementInsert ( sDimName, 'WaferSize_Item', sParent, SubsetGetSize ( sDimName, 'WaferSize_Item' ) + 1 );
EndIf;
iCount = iCount + 1;
End;
SubsetDestroy ( sDimName, 'WaferSize_Item' );
Declan Rodger
-
- Community Contributor
- Posts: 341
- Joined: Wed Nov 03, 2010 9:16 pm
- OLAP Product: tm1
- Version: 10 2 2 - 2.0.5
- Excel Version: From 2007 to 2013
- Location: Earth
Re: Dynamic Subset using MDX
Hi
I'm not sure ELPAR works in an MDX statement. Try "parent" instead.
Second comment: what if the FILTER returns more than one element as result? I think the 'Parent' function needs one element of which you want to query the parent.
UPDATE: just reading through the post of declanr - this is a fine solution as it also resolves the problem if in the filter you receive elements of which parents are not the same.
I'm not sure ELPAR works in an MDX statement. Try "parent" instead.
Second comment: what if the FILTER returns more than one element as result? I think the 'Parent' function needs one element of which you want to query the parent.
UPDATE: just reading through the post of declanr - this is a fine solution as it also resolves the problem if in the filter you receive elements of which parents are not the same.
-
- 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: Dynamic Subset using MDX
That's the one I was trying to think of (and it couldn't have been a more obviously named onemvaspal wrote:Hi
I'm not sure ELPAR works in an MDX statement. Try "parent" instead.

Declan Rodger