Page 1 of 1

How to use both HIERARCHIZE and TM1 sort together in MDX

Posted: Tue Jan 10, 2012 4:57 pm
by Gurumadheshwaran
Hi,

I am having an dimension with the following structure

All
Aaaa
Bbbbb
Ccccc
Ddddd

It has one parent and all leaf elements

I want the elements to be sorted in descending order with the hierarchy retained(the parent element retained)

I used the following MDX

{ HIERARCHIZE( {TM1SORT( {TM1SUBSETALL( [SubsetName] )}, DESC)} ) }

But it is not working, May i know whether the hierarchize and sort will work together or wont, if not is there any other solution to get this

Regards
Guru

Re: How to use both HIERARCHIZE and TM1 sort together in MDX

Posted: Tue Jan 10, 2012 8:36 pm
by tomok
{[All]}+{TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [DimName] )}, 0)}, DESC)}

Re: How to use both HIERARCHIZE and TM1 sort together in MDX

Posted: Wed Feb 01, 2012 5:40 pm
by Gurumadheshwaran
tomok wrote:{[All]}+{TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [DimName] )}, 0)}, DESC)}

Thanks tomok,

It worked good, but i complexed it using UNION :D

{UNION({TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dim_name] )}, 1)},
{TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [Dim_name] )}, 0)}, DESC)})}

Thanks again :)

Re: How to use both HIERARCHIZE and TM1 sort together in MDX

Posted: Thu Oct 31, 2019 9:26 am
by MarenC
Hi,

from a technical point of view why do I need the curly braces around All but not around the TM1Sort?

{[All]} + TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [DimName] )}, 0)}, DESC)

Union({[All]}, TM1SORT( {TM1FILTERBYLEVEL( {TM1SUBSETALL( [DimName] )}, 0)}, DESC))

Maren

Re: How to use both HIERARCHIZE and TM1 sort together in MDX

Posted: Fri Nov 01, 2019 5:18 pm
by Wim Gielis
A function that returns a set, does not need additional { } around them.
If, for example, an element is strung together by text, that text needs to be converted into a set (of 1 element here) so it needs { }