Hi there,
I'm trying to make a calculated member to display the result of dividing one value by another which shows the variance percentage between the [Measure Volume Actual] and [Measure Volume Plan] values. I'm making the following tests:
1. If the [Measure Volume Actual] or [Measure Volume Plan] are NULL then I'd like nothing to be displayed, i.e. NULL.
2. If the [Measure Volume Plan] is 0 then I would like 100 % displayed.
ELSE
3. (([Measure Volume Actual] - [Measure Volume Plan]) / [Measure Volume Plan]) * 100.
So I thought I'd write the following expression (FYI my measures are based on values in the measure dimensio hence the check to see what the [Measure Code] is):
CASE WHEN ([Measures].[Measure Volume Plan], [Measure].[Measure Code].[AT01]) IS NULL OR
([Measures].[Measure Volume Actual], [Measure].[Measure Code].[AT01]) IS NULL
THEN NULL
WHEN ([Measures].[Measure Volume Plan], [Measure].[Measure Code].[AT01]) = 0
THEN 100.00
ELSE ((([Measures].[Measure Volume Actual], [Measure].[Measure Code].[AT01]) -
([Measures].[Measure Volume Plan], [Measure].[Measure Code].[AT01])) /
([Measures].[Measure Volume Plan], [Measure].[Measure Code].[AT01])) * 100 END
I'm not too familiar with MDX so wrote this as a CASE statement which seems to work fine. However NULL values appear to be ignored so the first clause in the CASE statement is skipped and the second clause in the CASE statement is triggered. Hence my values are 100 %.
However this does not make sense as if I don't know the actual or plan values then I can't calculate a variance %. If neither of them are NULL but the plan value is 0 then I know the variance % will be 100 % and this avoids the divide by zero error.
After looking around most people talk about the NullProcessing option in the base measure. The base measures in my cube are [Measure Volume Plan] and [Measure Volume Actual]. I tried changing the NullProcessing option for both of these physical measures to Preserve however this didn't appear to do anything. If anyone has any thoughts I'd love to know how to do this correctly.
Kind regards,
Chris