
=IF(ABS(actual-expected)<=tolerance,"OK","Fail")
Related formulas
Value is between two numbers
To test if a value is within expected tolerance or not, and report "pass" or "fail", you can use a formula based on the IF and ABS functions. In the example shown, the formula in E5 is:
=IF(ABS(B5-C5)<=D5,"OK","Fail")
Inside the IF function, the expected value is subtracted from the measured or actual value. The result may be positive or negative, depending on the actual value, so the ABS function is used to convert the result to a positive number in all cases. This number is then compared to the allowed tolerance as a logical test inside IF. If the difference is less than or equal to the allowed tolerance, IF returns "OK". If not, IF returns "Fail". These messages can be customized as needed.

=IF(ABS(actual-expected)<=tolerance,"OK","Fail")
Related formulas
Value is between two numbers
To test if a value is within expected tolerance or not, and report "pass" or "fail", you can use a formula based on the IF and ABS functions. In the example shown, the formula in E5 is:
=IF(ABS(B5-C5)<=D5,"OK","Fail")
Inside the IF function, the expected value is subtracted from the measured or actual value. The result may be positive or negative, depending on the actual value, so the ABS function is used to convert the result to a positive number in all cases. This number is then compared to the allowed tolerance as a logical test inside IF. If the difference is less than or equal to the allowed tolerance, IF returns "OK". If not, IF returns "Fail". These messages can be customized as needed.