计算成员作为由元组和集合

时间:2015-07-16 20:51:27

标签: ssas mdx olap olap-cube ssas-2012

我希望在OLAP多维数据集上创建一个带有SQL Server数据工具分析服务的计算成员结合以下过滤方法:

元组

(
    [Enrolment Planning Actuals].[Year].&[1],
    [Enrolment Planning Actuals].[Attribute 1].&[Y],
    [Enrolment Planning Actuals].[Attribute 2].&[N],
    [Enrolment Planning Actuals].[Attribute 3].&[N],
    [Measures].[Count]
)

设为单个成员

SUM(    
    EXCEPT(
        [Enrolment Planning Actuals].[Year].[Year],
        {
            [Enrolment Planning Actuals].[Year].&[1]
        }
    ),
    [Measures].[Count]
)   

[Enrolment Planning Actuals].[Year]的成员值为1,2,3,4,我基本上希望计算出的成员提供[Measures].[Count]过滤:

  • 包括所有[Enrolment Planning Actuals].[Year]个成员,但不包括[Enrolment Planning Actuals].[Year].&[1]
  • [Enrolment Planning Actuals].[Attribute 1].&[Y]
  • [Enrolment Planning Actuals].[Attribute 2].&[N]
  • [Enrolment Planning Actuals].[Attribute 3].&[N]

我认识到SUM函数可能是尝试组合这些过滤器的错误方法。

我发现文章MDX Calculated member filter by dimension attribute的接受答案在这一点上格外有用。

或许从根本上说,这种思维方式存在问题。欢迎提出建议,谢谢。

2 个答案:

答案 0 :(得分:2)

你几乎就是那个伙伴。

只是扩展settuple的概念,并添加crossjoin*的概念,以下是应该运作的内容:

WITH MEMBER Measures.YourCalculatedMember AS

SUM(
    EXCEPT(
            [Enrolment Planning Actuals].[Year].[Year],
            {
                [Enrolment Planning Actuals].[Year].&[1]
            }
          ) *
    [Enrolment Planning Actuals].[Attribute 1].&[Y] *
    [Enrolment Planning Actuals].[Attribute 2].&[N] *
    [Enrolment Planning Actuals].[Attribute 3].&[N]
    ,
    [Measures].[Count]
  )

答案 1 :(得分:1)

我认为您甚至可以放弃度量并在其中一个属性层次结构上创建成员。然后你可以使用不同的措施:

WITH MEMBER [Enrolment Planning Actuals].[Attribute 1].[YourCalculatedMember] AS
SUM(
    EXCEPT(
            [Enrolment Planning Actuals].[Year].[Year],
            {
                [Enrolment Planning Actuals].[Year].&[1]
            }
          ) *
    [Enrolment Planning Actuals].[Attribute 1].&[Y] *
    [Enrolment Planning Actuals].[Attribute 2].&[N] *
    [Enrolment Planning Actuals].[Attribute 3].&[N]
  )
SELECT
   {
     [Measures].[Count],
     [Measures].[Revenue]
   } on 0,
   {  
     [Enrolment Planning Actuals].[Attribute 1].[YourCalculatedMember], 
     [Enrolment Planning Actuals].[Attribute 1].&[Y]
   } on 1
FROM [YourCube];