MDX Scope Total Calculation with condition


MDX Scope Total Calculation with condition



I recently encounter an issue with using scope to calculate grand total. Example I've create a measure :


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



This measure to ensure amount2 (SalesInvoiceLine2_Amt) only appear when another measure (Amount) have value. But now the issue is my grand total for Amount2 doesn't total based on above condition, instead it sum up all amount2. I've try to use scope but seems doesnt work as well.


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



The total for [Test Invoice 2 Amt] should be 500+ 200 = 700.
Thanks in advance.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter