Page 1 of 1

MDX to sort Elements based on Substring

Posted: Wed Dec 09, 2009 3:00 am
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

Re: MDX to sort Elements based on Substring

Posted: Wed Dec 09, 2009 11:03 pm
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
)
}

Re: MDX to sort Elements based on Substring

Posted: Thu Dec 10, 2009 9:16 pm
by GPC
Thankyou standtrue - that works well.