在MDX中,显示所有维度成员的member_key的最佳方法是什么?

时间:2014-10-28 17:41:37

标签: mdx

在以下示例中,如何使用“member_key”显示[广告名称昏暗]。[广告名称]。[名称] .ALLMEMBERS?换句话说,要显示所有广告的唯一ID而不是它的名称吗?

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 个答案:

答案 0 :(得分:1)

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

希望这会有所帮助:

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];