MDX错误与聚合

时间:2015-03-16 16:33:14

标签: ssas mdx

我对MDX有以下查询

CREATE 
  MEMBER CURRENTCUBE.[Measures].[Estimating Accuracy Labour Hours] AS 
    Sum
    (
      CASE 
        WHEN 
              (1
              - 
                  [Measures].[Estimation Difference]
                / 
                  Aggregate
                  (
                    [Measures].[Actual Labour Hours]
                   ,[DISTRICTS D].[District]
                   ,[WORK  D].[Work].[Work  Description]
                  )
              )
            * 100
          > 0 
        THEN 
            (1
            - 
                [Measures].[Estimation Difference]
              / 
                Aggregate
                (
                  [Measures].[Actual Labour Hours]
                 ,[DISTRICTS D].[District]
                 ,[WORK  D].[Work].[Work  Description]
                )
            )
          * 100
        ELSE 0
      END
    ) 
   ,VISIBLE = 1 
   ,ASSOCIATED_MEASURE_ = 'WORK F' ; 

我收到以下错误

  

MdxScript(TEST)(52,71)太多的参数传递给了   AGGREGATE功能。函数的最大参数计数为2.

如何解决?

1 个答案:

答案 0 :(得分:1)

错误比大多数MDX错误消息更容易理解!

此代码段中有三个参数:

Aggregate
   (
         [Measures].[Actual Labour Hours]
        ,[DISTRICTS D].[District]
        ,[WORK  D].[Work].[Work  Description]
   )

以下是MSDN定义:https://msdn.microsoft.com/en-us/library/ms145524.aspx

  

聚合(Set_Expression [,Numeric_Expression])

按照此定义,将Numeric_Expression移动到结尾以及其前面的其他表达式:

Aggregate
   ( 
        ,[DISTRICTS D].[District]
        ,[WORK  D].[Work].[Work  Description]
        ,[Measures].[Actual Labour Hours]
   )

仍然应该是错误的。然后,您需要从前两个参数中创建一个元组:

Aggregate
   ( 
        {(
         [DISTRICTS D].[District]
        ,[WORK  D].[Work].[Work  Description]
        )}
        ,[Measures].[Actual Labour Hours]
   )

您的错误消息现在应该消失。