Forum Discussion
Trouble Calculating Percentage Difference
- 3 years ago
wrap the sum functions in a calculate function to change the context
e.g. OverCost = CALCULATE( SUM (Actuals[ActualCosts])) - CALCULATE(SUM (Plans[PlannedCosts])) / CALCULATE(SUM (Plans[PlannedCosts]))
Indeed I'm still getting the issue in OverDuration.
I've included ALLEXCEPT in over duration formula and now is returning values but they are incorrect. For example I manually calculated the first value that should be -92,35%, and the dax formula returns -65,56%
OverDuration = CALCULATE(CALCULATE(SUM(Actual_Duration[ActualDuration])) - CALCULATE(SUM(Plans[PlannedDuration])), ALLEXCEPT(Plans, Plans[PlannedDuration])) / CALCULATE(SUM(Plans[PlannedDuration]), ALLEXCEPT(Plans, Plans[PlannedDuration]))
The other formula for OverCost is working but I didn't include the ALLEXCEPT, I also had to include the IF to avoid NaN divide by zero error:
OverCost = IF( CALCULATE(SUM(Plans[PlannedCosts])) = 0, 0, (CALCULATE(CALCULATE(SUM(Actuals[ActualCosts])) - CALCULATE(SUM(Plans[PlannedCosts]))) / CALCULATE(SUM(Plans[PlannedCosts])) )) |
I've tried a similar calculation and i'm not getting the same error. Do you have a copy of the PBI file i could look at?
- VanNostrand3 years agoRegular Visitor
Hello,
In the meantime I've updated the ALLEXCEPT and it seems that now is working:
ALLEXCEPT(Plans, Plans[ProjectID])
thansk for the help.