带条件的MDX范围总计计算

时间:2018-07-01 04:16:40

标签: ssas mdx

我最近在使用范围计算总计时遇到一个问题。示例我创建了一个度量:

CREATE MEMBER CURRENTCUBE.[Measures].[test Invoice 2 Amt]
AS IIF(ISEMPTY([Measures].[Amount]), NULL, [Measures].[SalesInvoiceLine2_Amt]),
FORMAT_STRING = "#,#.00",
VISIBLE = 1;

此度量以确保只有当另一个度量(金额)具有值时才显示金额2(SalesInvoiceLine2_Amt)。但是现在的问题是我的Amount2总计不是基于上述条件的总计,而是总计了全部amount2。我尝试使用范围,但似乎也无法正常工作。

CREATE MEMBER CURRENTCUBE.[Measures].[test Invoice 2 Amt]
AS IIF(ISEMPTY([Measures].[Amount]), NULL, [Measures].[SalesInvoiceLine2_Amt]),
FORMAT_STRING = "#,#.00",
VISIBLE = 1;
SCOPE
(
[Measures].[test Invoice 2 Amt]
);
THIS = SUM(IIF(ISEMPTY([Measures].[Amount]), NULL, [Measures].[SalesInvoiceLine2_Amt])) ;
End Scope;

[Item]  [Amount]  [test Invoice 2 Amt]  [SalesInvoiceLine2_Amt]
  A                                            200
  B        100           500                   500
  C                                            300
  D        600           200                   200
Total      700         11000                 11000 

[测试发票2 Amt]的总数应为500+ 200 = 700。 提前致谢。

0 个答案:

没有答案