SSAS MDX滚动总计不同的日期范围

时间:2015-11-06 14:14:02

标签: sql ssas mdx cube

我正在使用以下MDX公式计算成员的财务多维数据集:

IIF
 (
  [Chart Of Accounts].[Account Sub Group].CurrentMember 
   = 
  [Chart Of Accounts].[Account Sub Group].&[RESULT-CURRENT YEAR], 
  [Measures].[Amount GL YTD], 
  SUM
     (
      ParallelPeriod
                    (
                     [Date].[Year -  Quarter -  Month -  Date].[Year],
                     100,
                     [Date].[Year -  Quarter -  Month -  Date].CurrentMember
                    )
      :
      [Date].[Year -  Quarter -  Month -  Date].CurrentMember,
      [Measures].[Amount GL]
     )
 )

一切按预期工作。 [RESULTS-CURRENT YEAR]显示YTD的正确总数,而其他每个条目都显示从开始时间开始的总计。除[RESULTS-CURRENT YEAR]所在的权益汇总之外。它还会从时间开始添加总计,这会使我的数据透视表上的总权益膨胀。

关于我如何纠正这个问题的任何想法?

Explanation Summary

1 个答案:

答案 0 :(得分:1)

我不明白这个问题,但我注意到的一件事是您使用了=但是要表示mdx中成员的平等,您应该使用IS

IIF
 (
  [Chart Of Accounts].[Account Sub Group].CurrentMember 
   IS
  [Chart Of Accounts].[Account Sub Group].&[RESULT-CURRENT YEAR], 
  [Measures].[Amount GL YTD], 
  SUM
     (
      ParallelPeriod
                    (
                     [Date].[Year -  Quarter -  Month -  Date].[Year],
                     100,
                     [Date].[Year -  Quarter -  Month -  Date].CurrentMember
                    )
      :
      [Date].[Year -  Quarter -  Month -  Date].CurrentMember,
      [Measures].[Amount GL]
     )
 ) 

要跟踪发生的情况,请尝试将这些度量添加到您的多维数据集中,然后将它们放在麻烦列旁边的列中。他们回归了什么价值?。我怀疑它可能无法回复你的期望:

[Measures].[exploratory] AS
    [Date].[Year -  Quarter -  Month -  Date].CurrentMember.member_caption
[Measures].[exploratory2] AS
    [Chart Of Accounts].[Account Sub Group].CurrentMember.member_caption

此外,我想知道是否可以通过使用null来简化100年而不是回归:

IIF
 (
  [Chart Of Accounts].[Account Sub Group].CurrentMember 
   IS
  [Chart Of Accounts].[Account Sub Group].&[RESULT-CURRENT YEAR], 
  [Measures].[Amount GL YTD], 
  SUM
     (
      NULL:[Date].[Year -  Quarter -  Month -  Date].CurrentMember,
      [Measures].[Amount GL]
     )
 ) 

编辑

我怀疑在Grand Total行中,层次结构[Chart Of Accounts].[Account Sub Group]的当前成员是[All]成员,因此iif的布尔条件为false。您可以尝试修改:

IIF
 (
  (
   [Chart Of Accounts].[Account Sub Group].CurrentMember 
   IS [Chart Of Accounts].[Account Sub Group].&[RESULT-CURRENT YEAR]
  )
  OR
  (
   [Chart Of Accounts].[Account Sub Group].CurrentMember 
   IS [Chart Of Accounts].[Account Sub Group].[All]
  ) 
  ,[Measures].[Amount GL YTD] 
  ,SUM
     (
      NULL:[Date].[Year -  Quarter -  Month -  Date].CurrentMember,
      [Measures].[Amount GL]
     )
 )