MDX to include aliases in result
Posted: Wed Apr 28, 2021 7:36 am
Hi all,
I'm attempting to formulate some MDX in such a way as to return aliases rather than member captions.
I've found two issues around this subject on the tm1py github repo, but not much else!
https://github.com/cubewise-code/TM1py- ... /issues/28
https://github.com/cubewise-code/tm1py- ... /issues/31
Unfortunately, I just can't seem to figure it out from the information provided in those issues.
For more context... I'm using the PAX API (v 2.0.57 on 64 bit Excel) to call an ExecuteMDX command to create a cellset.
By default, the member names that are returned are the captions. Instead, I would like for a specific attribute/alias to be returned.
From the looks of the information presented in those github issues, it looks as though I need to look at using "WITH MEMBER" to try to achieve this, but I just can't figure out the syntax. Unfortunately I don't have access to the sample planning model, so can't just do as Marius suggests and try running his sample code there and then adapting.
Marius uses this in his example:
WITH MEMBER [plan_time].[AccountClass] AS
[}ElementAttributes_plan_chart_of_accounts].([}ElementAttributes_plan_chart_of_accounts].[AccountClass])
When I try to adapt this for my dimension, I just receive an error saying that the MDX is invalid.
My dimension is called ABC-Product. It has no hierarchies, other than the default (ABC-Product). I would like it's alias "Reporting" to be returned instead of "Caption".
My current MDX is as follows:
SELECT
{
[ABC-Product].[ABC-Product].[PROD_1],
[ABC-Product].[ABC-Product].[PROD_2]
}
ON 0,
[ABC-Period].[ABC-Period].[PER_1]
ON 1
FROM [ABC-MyCube]
WHERE
(
[ABC-Channel].[CHAN_1],
[ABC-Type].[TYPE_1]
)
I think I need to change it to something like the following:
WITH MEMBER [ABC-Product].[Caption] AS
[}ElementAttributes_ABC-Product].([}ElementAttributes_ABC-Product].[Reporting])
SELECT
{
[ABC-Product].[ABC-Product].[PROD_1],
[ABC-Product].[ABC-Product].[PROD_2]
}
ON 0,
[ABC-Period].[ABC-Period].[PER_1]
ON 1
FROM [ABC-MyCube]
WHERE
(
[ABC-Channel].[CHAN_1],
[ABC-Type].[TYPE_1]
)
Any advice would be very much appreciated. Thank you in advance!
I'm attempting to formulate some MDX in such a way as to return aliases rather than member captions.
I've found two issues around this subject on the tm1py github repo, but not much else!
https://github.com/cubewise-code/TM1py- ... /issues/28
https://github.com/cubewise-code/tm1py- ... /issues/31
Unfortunately, I just can't seem to figure it out from the information provided in those issues.
For more context... I'm using the PAX API (v 2.0.57 on 64 bit Excel) to call an ExecuteMDX command to create a cellset.
By default, the member names that are returned are the captions. Instead, I would like for a specific attribute/alias to be returned.
From the looks of the information presented in those github issues, it looks as though I need to look at using "WITH MEMBER" to try to achieve this, but I just can't figure out the syntax. Unfortunately I don't have access to the sample planning model, so can't just do as Marius suggests and try running his sample code there and then adapting.
Marius uses this in his example:
WITH MEMBER [plan_time].[AccountClass] AS
[}ElementAttributes_plan_chart_of_accounts].([}ElementAttributes_plan_chart_of_accounts].[AccountClass])
When I try to adapt this for my dimension, I just receive an error saying that the MDX is invalid.
My dimension is called ABC-Product. It has no hierarchies, other than the default (ABC-Product). I would like it's alias "Reporting" to be returned instead of "Caption".
My current MDX is as follows:
SELECT
{
[ABC-Product].[ABC-Product].[PROD_1],
[ABC-Product].[ABC-Product].[PROD_2]
}
ON 0,
[ABC-Period].[ABC-Period].[PER_1]
ON 1
FROM [ABC-MyCube]
WHERE
(
[ABC-Channel].[CHAN_1],
[ABC-Type].[TYPE_1]
)
I think I need to change it to something like the following:
WITH MEMBER [ABC-Product].[Caption] AS
[}ElementAttributes_ABC-Product].([}ElementAttributes_ABC-Product].[Reporting])
SELECT
{
[ABC-Product].[ABC-Product].[PROD_1],
[ABC-Product].[ABC-Product].[PROD_2]
}
ON 0,
[ABC-Period].[ABC-Period].[PER_1]
ON 1
FROM [ABC-MyCube]
WHERE
(
[ABC-Channel].[CHAN_1],
[ABC-Type].[TYPE_1]
)
Any advice would be very much appreciated. Thank you in advance!