MDX to sort Elements based on Substring

Post Reply
GPC
Posts: 51
Joined: Thu Aug 06, 2009 11:09 pm
OLAP Product: TM1
Version: 10.2.20100.123
Excel Version: 365
Location: Sydney

MDX to sort Elements based on Substring

Post by GPC »

Hi All,

I'm new to MDX but I want to sort the elements of a dimension based on a Substring of the element name. So I need something like this;

{
ORDER(
{ TM1FILTERBYLEVEL(
{TM1SUBSETALL( [Schedule] )}
,0)}
, SUBSTRING([Schedule],6,1), BDESC)
}

Of course the the syntax is wrong and I don't know if SUBSTRING or SUBST can be used in MDX. Can anyone point me in the right direction?

thanks,

Gregory
standtrue
Posts: 25
Joined: Sat Nov 07, 2009 5:37 am
OLAP Product: TM1, CX
Version: 9.5.2
Excel Version: 2007

Re: MDX to sort Elements based on Substring

Post by standtrue »

Substring doesn't work in subsets as far as I know, but here is one solution:

On your Schedule dimension create a text attribute called "SubString" (or whatever).

In your }ElementsAttributes_Schedule cube write a rule along the lines of:

['SubString'] = S: SUBST(!Schedule, 6, 1);

Now in your subset you can say:

{
order(
tm1filterbylevel([schedule].MEMBERS,0)
,[schedule].SubString
, bdesc
)
}
GPC
Posts: 51
Joined: Thu Aug 06, 2009 11:09 pm
OLAP Product: TM1
Version: 10.2.20100.123
Excel Version: 365
Location: Sydney

Re: MDX to sort Elements based on Substring

Post by GPC »

Thankyou standtrue - that works well.
Post Reply