# Value is within tolerance

To test if a value is within expected tolerance or not, you can use a formula based on the IF function and the ABS function. In the example shown, the formula in E5, copied down, is:

When the value in column B is within +/- .005 of 0.250 (from column C), the formula returns "OK". If not, the formula returns "Fail".

In this example the goal is to check if values in column B are within a tolerance of .005. If a value is within tolerance, the formula should return "OK". If the value is out of tolerance, the formula should return "Fail". The expected value is listed in column C, and the allowed tolerance is listed in column D. The solution is based on the IF function together with the ABS function.

### Core logic

To check if a value is within a given tolerance, we can use a simple logical test like this:

=ABS(actual-expected)<=tolerance // logical test

Inside the ABS function, the actual value is subtracted from the expected 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: negative values become positive and positive values are unchanged. The result from ABS is compared to the allowed tolerance with the logical operator less than or equal (<=). The expression returns TRUE when a value is less than or equal to the allowed tolerance, and FALSE if not.

### IF function

To complete the solution, we need to place the generic logical expression above into the IF function and providing values for a TRUE and FALSE result. The first step is to revise the generic expression above to use worksheet references:

ABS(B5-C5)<=D5 // logical test

Then, we drop the expression into the IF function as the *logical_test* argument:

When the logical test returns TRUE, IF returns "OK". When the logical test returns FALSE, IF returns "Fail". These messages can be customized as needed.

### List all values within tolerance

The basic concept explained above can be extended to list values within tolerance or out of tolerance with the FILTER function.

## Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

## Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.