Is it possible to use column aliases in MDX query?
I execute MDX using MSOLAP and I'd like to have a specific names for the columns returned.
Linkedserver and OPENROWSET is a one solution, but is there a way to specify column aliases in MDX query?
You can use calculated members to change names of dimension members (including measures).
So you could write your query as something like the following:
WITH MEMBER Measures.[NiceName1] as Measures.M1, Measures.[NiceName2] as M2
SELECT {Measures.[NiceName1], Measures.[NiceName2]} on 0
FROM [MyCube]
|||Using CM for that purposes is a very dangerous way.|||Thank you.
When running some examples, I'm still getting errors:
1. "Parser: The syntax for '.' is incorrect." for:
WITH MEMBER Measures.[Reseller Sales Amount] as Measures.M1, Measures.[Calendar Year].[CY 2004] as M2
SELECT
([Measures].[Reseller Sales Amount],[Date].[Calendar Year].[CY 2004]) ON 0
FROM [Adventure Works]
2. "The Reseller Sales Amount calculated member cannot be created because a member with the same name already exists." for:
WITH MEMBER Measures.[Reseller Sales Amount] as M2
SELECT
([Measures].[Reseller Sales Amount],[Date].[Calendar Year].[CY 2004]) ON 0
FROM [Adventure Works]
You're saying: "Using CM for that purposes is a very dangerous way."
What would be the best? Linkedserver and OPENROWSET only?
|||
Try reversing the syntax. (In other words NiceName1 was the new calculated member serving as an alias to M1 in my original example.)
You will lose the ability to do drillthrough on the calc members. Vladamir can comment on other concerns he may have about this approache.
|||Vladimir -
Why is this considered a bad practice? What other ways are there to accomplish this? You have me very curious...
Thanks,
John
No comments:
Post a Comment