Forum Discussion
MFranken
Jan 10, 2024Copper Contributor
End of IF statement causing issue, what am I doing wrong?
Trying to create a nested IF statement. I'm having a problem with the end standard false result. This formula works: =IF(G3472="","",IF(40-H3472-I3472<0,0,40-H3472-I3472)) But the exact same...
djclements
Jan 11, 2024Silver Contributor
MFranken This is a common problem caused by precision issues with the floating-point arithmetic method used by Excel. Please see: Floating-point arithmetic may give inaccurate results in Excel
One solution is to use the ROUND function to round the final results to the desired number of decimal places. For example, to round to 2 decimal places, use:
=IF(G3472="", "", IF(G3472-H3472-I3472<0, 0, ROUND(G3472-H3472-I3472, 2)))
Also worth mentioning, the MAX function can be used in this situation to simplify the formula as follows:
=IF(G3472="", "", MAX(ROUND(G3472-H3472-I3472, 2), 0))
Cheers!