Page 1 of 1

Need help on MDX

Posted: Mon Sep 11, 2023 7:57 am
by wbf
Hello, I need help on getting this MDX to work
In a cube view, I'm trying to set the values to be displayed for dim01, subjected to selection of dim2 element and attributes of the selected dim2 element

CURRENTMEMBER.PROPERTIES work fine but CURRENTMEMBER.PROPERTIES().PROPERTIES() doesn't work.

TM1SubsetToSet([dim01] ,
IIF([dim02].CURRENTMEMBER.PROPERTIES("att1").PROPERTIES("att2") = "xxx" , "subset_a" ,
IIF([dim02].CURRENTMEMBER.PROPERTIES("att1").PROPERTIES("att2") = "yyy" , "subset_b" , "subset_none")))

Can anyone help with the syntax.
Much appreciated!

Re: Need help on MDX

Posted: Mon Sep 11, 2023 8:42 am
by lotsaram
wbf wrote: Mon Sep 11, 2023 7:57 am CURRENTMEMBER.PROPERTIES work fine but CURRENTMEMBER.PROPERTIES().PROPERTIES() doesn't work.
And why on earth would you expect this to work?
CurrentMember is obviously a member
CurrentMember.Properties("propertyName") returns a string

You cannot pass a string into an expression which requires a member.

From a logic perspective what you want to do can still work but you will need to wrap the first CurrentMember.Properties in a StringToMember function.

Re: Need help on MDX

Posted: Mon Sep 11, 2023 9:05 am
by wbf
Thanks.

I've tried that as well - since it says invalid MDX expression I thought of just putting the simplified version which represents the idea.

TM1SubsetToSet([dim01] ,
IIF(StrToMember([dim02].CURRENTMEMBER.PROPERTIES("att1")).PROPERTIES("att2") = "xxx" , "subset_a" ,
IIF(StrToMember([dim02].CURRENTMEMBER.PROPERTIES("att1")).PROPERTIES("att2") = "yyy" , "subset_b" , "subset_none")))

Re: Need help on MDX

Posted: Mon Sep 11, 2023 9:20 am
by gtonkin
Have a look at the reference guide for more on how to use StrToMember per Lotsa's suggestion.

Re: Need help on MDX

Posted: Wed Sep 20, 2023 10:14 am
by wbf
Hi thanks for the advice. the following works

TM1SubsetToSet([dim01] ,
IIF(StrToMember("[dim02].["+[dim02].CURRENTMEMBER.PROPERTIES("att1")+"]").PROPERTIES("att2") = "xxx" , "subset_a" ,
IIF(StrToMember("[dim02].["+[dim02].CURRENTMEMBER.PROPERTIES("att1")+"]").PROPERTIES("att2") = "yyy" , "subset_b" , "subset_none")))

Basically, the member requires some "wrapping"