MDX计算具有命名集的成员

时间:2015-05-08 04:01:13

标签: mdx olap-cube

我是一个名为CWTD(当前周至今)销售额的计算成员,为了使其正常工作,我需要传递一个命名集昨天。

是否可以将命名集包含在Calculated Member中,以便我不必在select语句中传递命名集?

我之所以将此视为Power View,并未在字段列表中显示命名集。

示例:

WITH MEMBER [Measures].[CWTD Sales Test]
 AS Sum(
            PeriodsToDate(
                [Date].[NZLC Date].[NZLC Week],
                [Date].[NZLC Date].CurrentMember
            ),  
            [Measures].[Net Sales - Gross for IK]
        )
select 
  [Measures].[CWTD Sales Test] on columns,
  NON EMPTY [Product].[Product].[Product Group] on rows
from [Daily Sales]
where 
  Tail(NonEmpty([Date].[NZLC Date].[Day].MEMBERS,[Measures].[Gross Sales]),1)

无论如何我可以将where部分包含在我的计算成员中吗?

1 个答案:

答案 0 :(得分:2)

@Dan回答了你的问题,但也作为另一种选择:

WITH 
SET [Yesterday] AS
  Tail(
    NonEmpty(
      [Date].[NZLC Date].[Day].MEMBERS
     ,[Measures].[Gross Sales]
    )
  )
MEMBER [Measures].[CWTD Sales Test] AS
  SUM(
    WTD([Yesterday].ITEM(0).ITEM(0))  
     ,[Measures].[Net Sales - Gross for IK]
  )
SELECT 
  [Measures].[CWTD Sales Test] ON 0,
  NON EMPTY [Product].[Product].[Product Group] ON 1
FROM [Daily Sales];