MDX Order to Sort

Post Reply
kenship
Regular Participant
Posts: 194
Joined: Thu May 30, 2013 1:41 pm
OLAP Product: Cognos
Version: Planning Analytics 2.0.7
Excel Version: 2010

MDX Order to Sort

Post by kenship »

Hi, I'm reading and testing to use MDX Order function to sort dimension element based on cube value. I think I got 80-90% but Expression Window in Subset Editor still gives me syntax error. Here's information:

Cube Name: Cube
Dimensions: DimA t0 DimE (with "$" being the measure in "DimE")
Dimension to be sorted : DimC

Here's my MDX code:

Code: Select all

{
ORDER(
            {TM1FILTERBYLEVEL(
                                               {TM1SUBSETALL( [ Cube ] )}
                                         ,0)
             }
           ,[Cube].(
                          [DimA].[(All Dim A)]
                         ,[DimB].[(All Dim B)]
                         ,[DimD].[(All Dim D)]
                         ,[DimE].[$]
                        )
                         ,[DimC] BDESC

        )
}
Thanks!
Kenneth
Wim Gielis
MVP
Posts: 3113
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: MDX Order to Sort

Post by Wim Gielis »

To name just 1 thing, I would expect to see TM1SubsetAll of DimC not of Cube.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
kenship
Regular Participant
Posts: 194
Joined: Thu May 30, 2013 1:41 pm
OLAP Product: Cognos
Version: Planning Analytics 2.0.7
Excel Version: 2010

Re: MDX Order to Sort

Post by kenship »

Wim Gielis wrote: Wed Dec 11, 2019 7:15 pm To name just 1 thing, I would expect to see TM1SubsetAll of DimC not of Cube.
Ouch! You're right Wim.

I figured it out.

Here's what works for me:

Code: Select all

{
ORDER	(
		{ TM1FILTERBYLEVEL	(
						{TM1SUBSETALL(DimC)}
						,0
						)
		}
		,[Cube].(
				[DimA].[(ALL Dim A)]
				, [DimB].[(All Dim B)]
				, [DimD].[(All Dim D)]
				, [DimE].[$]
				), BDESC
		)
}

Post Reply