Tolerance within formula for currency not working

FatalLordes

Board Regular
Joined
Dec 22, 2017
Messages
76
Office Version
  1. 365
Platform
  1. Windows
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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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