Page 1 of 1

MDX for retrieving cube value in SubsetToSet

Posted: Tue Nov 19, 2024 5:21 pm
by CRP0021
Hi all,

Just need some assistance in writing an MDX statement to pull in a cube value and pass it in to the function TM1SubsetToSet.

Here are some details:
-Dimension name is Location
-Lookup cube name is User Settings
-Measure trying to retrieve subset name from is Location_Subset_Name

I can get the function TM1 SubsetToSet function to work when I hard-code the location name:

TM1SubsetToSet ( [Location].[Location] , "New_Location" , "public")

And I tried wrapping this insdie the TM1SubsetToSet but I'm not having any luck:
StrToMember( "[Location].[" + CoalesceEmpty( [User Settings].(StrToMember( "[}Clients].[" + UserName + "]"), [User Settings].[Location_Subset_Name]), "<default>" ) + "]"),

My end goal is to have the name of the subset which changes by user be dynamically set in the Location dim with the TM1SubsetToSet function

Any advice would be much appreciated!

Re: MDX for retrieving cube value in SubsetToSet

Posted: Tue Nov 19, 2024 9:14 pm
by burnstripe
Try this:

Code: Select all

TM1SubsetToSet (
	[Location].[Location] 
	, "" + [User Settings].(StrToMember( "[}Clients].[" + UserName + "]"), [User Settings].[Location_Subset_Name]) + "" 
	, "public")

Re: MDX for retrieving cube value in SubsetToSet

Posted: Tue Nov 19, 2024 10:24 pm
by CRP0021
That did the trick thank you!

Re: MDX for retrieving cube value in SubsetToSet

Posted: Wed Nov 20, 2024 1:39 am
by Wim Gielis
I think that you can remove "" + and + "" unless Burnstripe is sure they are needed ?

Re: MDX for retrieving cube value in SubsetToSet

Posted: Wed Nov 20, 2024 7:29 pm
by burnstripe
Wim Gielis wrote: Wed Nov 20, 2024 1:39 am I think that you can remove "" + and + "" unless Burnstripe is sure they are needed ?
They were needed for passing the subset name within the tm1subsettoset

With the "" it returns as this and works
TM1SubsetToSet ([Location].[Location] , "my subset" , "public")

Without the "" it returns as this and fails
TM1SubsetToSet ([Location].[Location] , my subset , "public")

Re: MDX for retrieving cube value in SubsetToSet

Posted: Wed Nov 20, 2024 11:20 pm
by Wim Gielis
burnstripe wrote: Wed Nov 20, 2024 7:29 pm
Wim Gielis wrote: Wed Nov 20, 2024 1:39 am I think that you can remove "" + and + "" unless Burnstripe is sure they are needed ?
They were needed for passing the subset name within the tm1subsettoset

With the "" it returns as this and works
TM1SubsetToSet ([Location].[Location] , "my subset" , "public")

Without the "" it returns as this and fails
TM1SubsetToSet ([Location].[Location] , my subset , "public")
I see what is happening. I removed them, but then PAW put them there. So yes they are needed. Solved :-)