问题
Here is my MDX query below:
SELECT
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,NonEmpty([AccSetting].[User N].[User N] * [Cur Log].[Cur Log ID].Children) ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
http://i.stack.imgur.com/0yDHg.png
UserID =113 is a hierarchies and a want to get the userN of it
I want to return exactly UserName of UserID =113 on Rows. but I'm not sure how to do it.
回答1:
If you just want the name and nothing else then this should do it:
SELECT
{} ON COLUMNS
,[AccSetting].[User N].[User N] ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
If you want to turn the name into a measure then something like the following, with a custom measure should help:
WITH
MEMBER [Measures].[userName] AS
[AccSetting].[User N].CurrentMember.Member_Caption
SELECT
{} ON 0
,{
[Measures].[userName]
,[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON 1
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
To return the columns you mentioned in comment this should work:
SELECT
NON EMPTY
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,NON EMPTY
[AccSetting].[User N].[User N].MEMBERS
* [Cur Log].[Cur Log ID].MEMBERS
ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
EDIT
Answer in this article:
Get hierarchies valuesName mdx
回答2:
Try having this way:
with dynamic set UserN as
NonEmpty(
[AccSetting].[User N].[User N].members * [Cur Log].[Cur Log ID].Children
,
[AccSetting].[Ag ID].currentmember
*
{
[Measures].[Amt Exrate],
[Measures].[Comm Exrate]
}
)
SELECT
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,UserN ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
来源:https://stackoverflow.com/questions/31425656/mdx-get-username-where-userid