MDX Get UserName Where UserID

自作多情 提交于 2019-12-11 12:51:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!