logo
search
Function Problems

Excel Formula to Check if a Number is Within 20 Percent

Huda QurayshiHuda Qurayshi Oct 1, 2026 868 views

Question details

The user needs an Excel formula to determine if a value in one column falls within a 20% range (above or below) of a corresponding value in another column.

Excel Formula to Check if a Number is Within 20 Percent
Product
Excel
Device & OS
not provided
Scenario
Comparing two numerical columns to verify if their difference falls within a specified percentage tolerance.
Observed behavior
The user wants to automatically output a specific text label, such as "within" or "out", based on whether the absolute difference between two numbers is less than or equal to 20% of the baseline number.
Before you start

Ensure your data columns contain numeric values formatted as numbers, and identify which column will act as your baseline reference for calculating the 20 percent threshold.

Solution 1Recommended

Use IF and ABS Functions to Calculate the Percentage Difference

This method uses the ABS function to calculate the absolute difference between two values and the IF function to return a specific text result based on whether the difference is within the 20% limit.

The ABS function is essential here because it ensures that both positive and negative differences (values above or below the baseline) are treated equally as absolute numbers. By multiplying the reference value by 20%, you establish the acceptable tolerance range.

1
Select the output cell

Click on cell C1, or the first cell in the column where you want the "within" or "out" result to appear.

2
Enter the formula

Type the formula =IF(ABS(B1-A1)<=20%*A1,"within","out") into the formula bar. In this example, A1 is the baseline reference value and B1 is the value being compared.

3
Apply to the entire column

Press Enter to see the result for the first row. Then, click and drag the small green fill handle at the bottom-right corner of cell C1 down the column to apply the formula to your remaining data.

Fixing a #NAME? Error: If Excel returns a #NAME? error, your regional language settings might require different function names or list separators. Try replacing the commas in the formula with semicolons, like this: =IF(ABS(B1-A1)<=20%*A1;"within";"out").
Smart Spreadsheet Tool

Easily Calculate Percentage Differences in WPS Spreadsheet

WPS Spreadsheet fully supports advanced mathematical and logical functions like IF and ABS, allowing you to accurately calculate percentage tolerances and automate data analysis just like you would in Microsoft Excel.

  1. 1. Open your dataset in WPS Spreadsheet: Launch WPS Office, open your spreadsheet document, and locate the two columns of numbers you want to compare.
  2. 2. Select the target cell: Click on the cell where you want the comparison result to be displayed.
  3. 3. Input the IF and ABS formula: Type =IF(ABS(B1-A1)<=20%*A1,"within","out") into the cell and press Enter.
  4. 4. Fill the formula down: Double-click or drag the fill handle in the bottom-right corner of the cell to automatically calculate the percentage difference for the rest of your rows.
100% compatible with Microsoft Excel formulas, functions, and file formats.Intuitive interface for managing large datasets and complex calculations easily.Built-in error checking to help troubleshoot formula syntax quickly.Free and lightweight alternative for everyday spreadsheet tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Can I change the 20 percent threshold to a different value?

Yes. You can easily adjust the threshold by replacing "20%" in the formula with any other percentage, such as "15%" or "50%". Alternatively, you can replace the "20%" with a cell reference (e.g., $D$1) that contains your target percentage, allowing you to update the threshold without editing the formula again.

How do I change the output text from "within" and "out"?

In the formula =IF(ABS(B1-A1)<=20%*A1,"within","out"), simply replace the words "within" and "out" with your preferred terms, such as "Pass" and "Fail" or "Acceptable" and "Review". Make sure to keep the double quotation marks around your custom text.

Why does the formula return an error when comparing empty cells?

If the reference cell (A1) is empty or contains text instead of a number, the mathematical calculation will fail, resulting in a #VALUE! error. Ensure that both columns contain valid numerical data before applying the formula.