MDX Filter by level 1 and not level 0
-
- Posts: 18
- Joined: Wed Oct 15, 2014 9:33 am
- OLAP Product: Cognos
- Version: 10.2
- Excel Version: 2013
MDX Filter by level 1 and not level 0
Hi, this is an MDX for TM1 subset create question.
We want display level 1 and remove level 0 rom the subset.
Many thanks
We want display level 1 and remove level 0 rom the subset.
Many thanks
-
- MVP
- Posts: 1828
- 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: MDX Filter by level 1 and not level 0
Normally for MDX I would recommend writing it yourself and in that case the TM1 MDX Primer document (which can be found by searching this forum or google) would be your first port of call.
But for a simple TM1FilterByLevel you may as well just use the "record expression" option in the subset editor and create it using the wizard. Just record it like you can a macro in excel, go through the steps that you would to manually select only level 1 elements i.e. Expand all => Filter by level. Then stop recording and save your subset with the expression included.
But for a simple TM1FilterByLevel you may as well just use the "record expression" option in the subset editor and create it using the wizard. Just record it like you can a macro in excel, go through the steps that you would to manually select only level 1 elements i.e. Expand all => Filter by level. Then stop recording and save your subset with the expression included.
Declan Rodger
-
- Posts: 18
- Joined: Wed Oct 15, 2014 9:33 am
- OLAP Product: Cognos
- Version: 10.2
- Excel Version: 2013
Re: MDX Filter by level 1 and not level 0
What would I need to display only the elements of level 1 and it was not possible to choose the elements of level 0 .
I am having an dimension with the following structure
-aaa
| - a11
| - a12
| - a12
-bbb
| - b14
| - b21
I need what would happen
aaa
bbb
I am having an dimension with the following structure
-aaa
| - a11
| - a12
| - a12
-bbb
| - b14
| - b21
I need what would happen
aaa
bbb
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: MDX Filter by level 1 and not level 0
bogdan wrote:We want display level 1 and remove level 0 rom the subset.
Recording is good to start off but you can end up with a crapola expression if you end up with the {TM1SubsetBasis} nonsense in the recording. Like here the {TM1SubsetBasis} is meaningless outside its immediate context:declanr wrote:But for a simple TM1FilterByLevel you may as well just use the "record expression" option in the subset editor and create it using the wizard.
Code: Select all
{TM1FILTERBYLEVEL( {TM1SubsetBasis()}, 1)}
Code: Select all
{TM1FILTERBYLEVEL( {TM1SUBSETALL( [Account] )}, 1)}
If you have an existing subset that you wish to filter for level-1 elements then you can use something like this:
Code: Select all
{TM1FILTERBYLEVEL( {[Account].[YOUR_SUBSET_NAME_GOES_HERE]}, 1)}
Code: Select all
{TM1FILTERBYLEVEL( {TM1SUBSETTOSET( [Account], "YOUR SUBSET NAME GOES HERE" )}, 1)}
Robin Mackenzie
-
- Posts: 18
- Joined: Wed Oct 15, 2014 9:33 am
- OLAP Product: Cognos
- Version: 10.2
- Excel Version: 2013
Re: MDX Filter by level 1 and not level 0
Code: Select all
{TM1FILTERBYLEVEL( {TM1SUBSETALL( [Account] )}, 1)}
-
- Posts: 18
- Joined: Wed Oct 15, 2014 9:33 am
- OLAP Product: Cognos
- Version: 10.2
- Excel Version: 2013
Re: MDX Filter by level 1 and not level 0

How do I remove the select child elements ?
-
- MVP
- Posts: 1828
- 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: MDX Filter by level 1 and not level 0
So the MDX does provide what you wanted but you want the user to not have the option to expand the level 1 element?bogdan wrote: How do I remove the select child elements ?
If that's the case, that just isn't how the subset editor/cube viewer works.
You would have 2 options I can think of from the top of my head:
1/ Remove security access to the level 0 elements.
2/ Use an active form with your subset in the tm1rptrow formula and set it to not be expandable.
Declan Rodger
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: MDX Filter by level 1 and not level 0
That is just the way the subset editor works. The expression gives you a starting point, after which users can go on and do drilldown if they wish.
Robin Mackenzie
-
- Posts: 18
- Joined: Wed Oct 15, 2014 9:33 am
- OLAP Product: Cognos
- Version: 10.2
- Excel Version: 2013
Re: MDX Filter by level 1 and not level 0
And with the help of functions "HIERARCHIZE" or "EXPAND" it is impossible to exclude the child elements?
-
- MVP
- Posts: 2836
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: MDX Filter by level 1 and not level 0
As has been already explained, an MDX query will only return elements that match your query as a subset list. It does not change the underlying structure of the dimension. So, if my MDX returned just one element called "All Elements", which is a rollup of all the elements in the dimension, then there is nothing I can do to stop the user from clicking on the plus sign next to All Elements and expanding the list short of taking away their security rights to those children.bogdan wrote:And with the help of functions "HIERARCHIZE" or "EXPAND" it is impossible to exclude the child elements?