Tolerance within formula for currency not working

FatalLordes

New Member
Joined
Dec 22, 2017
Messages
26
Ok, I'm no Excel expert - very basic but I use google to work out things and I generally work things out myself. But I'm stumped on this formula which uses IF statement and ABS for tolerance:

=IF(ABS(B7-B4)<=0.05,"OK",IF(B7>B4,"Over",IF(B7<B4,"Under")))

Both B7 and B4 are currency cells (formatted $0.00). I'm trying to have a tolerance of 0.05. Assuming B4 is $41.66, it works saying "Ok" if B7 is $41.61, or says "Under" if B7 is $41.60 BUT it fails if B7 is $41.71 because it says "Over" when it should say "Ok" as within the +/- $0.05c range. If B7 is $41.70 it works and says "Ok", however, but not when $41.71?? Why is this? And how do I fix it?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I worked it out! I needed to add in the ROUND function.

=IF(ROUND(ABS(B7-B4),2)<=0.05,"OK",IF(B7>B4,"Over","Under"))
 
Upvote 0
It called "Floating point"
In fact, if in any cell you type = B7-B4 with B7=41.715, B4 = 41.66, then hit F9 (evaluate formula) you can see actual result is 0.50000043
Beside round function as your solution you could try:

=IF(ABS(B7-B4)<=0.05001,"OK",IF(B7>B4,"Over",IF(B7<B4,"Under")))

or

=INDEX({"UNDER","OK","OVER"},MATCH(TRUE,B7<=B4+{-0.05001,0.05001,1000000},0))
 
Upvote 0
@FatalLordes The link below explains the issue


then hit F9 (evaluate formula) you can see actual result is 0.50000043
I think you meant 0.500000000000043

1653377501285.png
 
Upvote 0

Forum statistics

Threads
1,215,385
Messages
6,124,626
Members
449,174
Latest member
Anniewonder

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