DAX divide issue

Cime14

New Member
Joined
Dec 19, 2017
Messages
30
Hi all,

how could I correct the formula in power pivot measures to get value 0% where numerator and denominator are both 0?
I was able to resolve this issue where only denominator is 0 but I am lost when both are.

My current formula:
=DIVIDE(CALCULATE(SUM(SAP_Final[MTD]));CALCULATE(SUM(FCRS_PM[MTD]));1)-1

Would appreciate your help!

1633686200012.png


Have a nice day!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
You could wrap it in an IFERROR(your formula, 0) function.
 
Upvote 0
How does it not solve your problem?
 
Upvote 0
With my current formula: =DIVIDE(CALCULATE(SUM(SAP_Final[MTD]));CALCULATE(SUM(FCRS_PM[MTD]));1)-1 I am getting -100%.

1634050987881.png
 
Upvote 0
Oh, sorry, I completely misinterpreted your formula. Try something like:

=VAR PctChange = DIVIDE(CALCULATE(SUM(SAP_Final[MTD]));CALCULATE(SUM(FCRS_PM[MTD]));1)
RETURN IF(PctChange=0,0,PctChange-1)
 
Upvote 0
Now I am getting value 0% on all lines...except on a line I would want to - there is still -100% ?
 
Upvote 0
Sorry I meant to change the 1 in the DIVIDE function to 0 but I can’t see how that would give you 0 everywhere else as it was
 
Upvote 0
worth noting that the result of 0/0 is a philosophical challenge: it could be 0, 1 or Infinity. Why not explicitly test for both figures being 0 with an IF function wrapping the division. If I've understood correctly it would read:

=IF(AND(SUM(SAP_Final[MTD])=0, SUM(FCRS_PM[MTD])=0), 0, DIVIDE(SUM(SAP_Final[MTD]), SUM(FCRS_PM[MTD]), 1)-1) but i'm not sure why your subtracting 1 from the result of the divide as that applies to all results returned. Also, I dont think (but happy to be proved wrong) that you need to wrap the SUM calculations in CALCULATE. I think you could define two additional measures as follows:

SumFinal=SUM(SAP_Final[MTD])
SumFCRS_PM=SUM(FCRS_PM[MTD])

Your percentage measure then becomes:

SAP_PM_MTD_%=IF(AND(SumFinal=0, SumFCRS_PM=0), 0, DIVIDE(SumFinal, SumFCRS_PM,0))

PS. you might need to change my commas into semicolons.

HTH
 
Upvote 0
Solution

Forum statistics

Threads
1,223,698
Messages
6,173,897
Members
452,536
Latest member
Chiz511

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top