In MDX, What is the best way to display the member_key of all dimension members?

China☆狼群 提交于 2020-01-16 05:10:13

问题


In the following example, how can I use the "member_key" for displaying the [Ad Name Dim].[Ad Name].[Name].ALLMEMBERS? in other words, to display ALL ads unique IDs instead of it's names ?

WITH 
  SET [Selected Measures] AS 
{
  [Measures].[Cost]
 ,[Measures].[Clicks]
} 
  MEMBER [Measures].[MinDate] AS 
Head
(
  NonEmpty
  (
    [Time Dim].[Time Dim].[Month] //<<to return minimum month but could be changed to a different level
   ,(
      [Selected Measures]
     ,[Ad Name Dim].[Ad Name].CurrentMember
    )
  )
 ,1
).Item(0).Item(0).Member_Caption 
SELECT 
  {
    [Selected Measures]
   ,[Measures].[MinDate]
   } ON COLUMNS
 ,NonEmpty
  (
    (
      [Ad Name Dim].[Ad Name].[Name].ALLMEMBERS
     ,
        ClosingPeriod
        (
         [Time Dim].[Time Dim].[Month]
        ,[Time Dim].[Time Dim].[All Time]
    ).Lag(3)
      : 
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
       )
   )
 ) ON ROWS
FROM [CubeName];

回答1:


Reference: http://bisherryli.com/2012/05/07/mdx-6-use-unique_name-or-member_key-member-property/

Hopefully this helps:

WITH 
SET [Selected Measures] AS 
{
  [Measures].[Cost]
 ,[Measures].[Clicks]
} 
MEMBER [Measures].[MinDate] AS 
Head
(
  NonEmpty
  (
    [Time Dim].[Time Dim].[Month] //<<to return minimum month but could be changed to a different level
   ,(
      [Selected Measures]
     ,[Ad Name Dim].[Ad Name].CurrentMember
    )
  )
 ,1
).Item(0).Item(0).Member_Caption 
MEMBER [Measures].[MemberKey] AS 
  [Ad Name Dim].[Ad Name].currentmember.member_key
SELECT 
  {
   [Measures].[MemberKey]
   ,[Selected Measures]
   ,[Measures].[MinDate]
   } ON COLUMNS
 ,NonEmpty
  (
    (
      [Ad Name Dim].[Ad Name].[Name].ALLMEMBERS
     ,
        ClosingPeriod
        (
         [Time Dim].[Time Dim].[Month]
        ,[Time Dim].[Time Dim].[All Time]
    ).Lag(3)
      : 
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
       )
   )
 ) ON ROWS
FROM [CubeName];


来源:https://stackoverflow.com/questions/26614958/in-mdx-what-is-the-best-way-to-display-the-member-key-of-all-dimension-members

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