Fix Excel IF Formula Results for Matching Values
Question details
The user needs an IF formula to compare values that appear identical in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- An IF formula compares two cells and returns a dash when they match or zero when they differ.
- Observed behavior
- Some comparisons return unexpected results even though the displayed values appear identical.
Identify the two cells being compared and the decimal precision relevant to your data. Use Home > Increase Decimal to check whether the displayed values hide decimal differences.
Round both values before comparing them in Excel
Use this method when calculated values look identical but differ in digits beyond the displayed precision.
Select the cells being compared and use Home > Increase Decimal to display more decimal places.
Select the result cell and enter =IF(ROUND(A1,9)=ROUND(B1,9),"-",0), replacing A1 and B1 with your actual cell references.
Change both instances of 9 to the number of decimal places appropriate for your data, then press Enter.
Drag the result cell's fill handle down to apply the formula to other rows, and check the results.

Compare rounded values with IF in WPS Spreadsheets
Use IF and ROUND in WPS Spreadsheets to compare values at the precision your worksheet requires.
- 1. Open the workbook: In WPS Spreadsheets, select Open and choose your Excel workbook.
- 2. Enter the comparison: Select a result cell and enter =IF(ROUND(A1,9)=ROUND(B1,9),"-",0), replacing the references with the cells you want to compare.
- 3. Set the precision: Change both instances of 9 to the required number of decimal places and press Enter.
- 4. Copy and save: Drag the fill handle to apply the formula to other rows, then select Save to save the workbook.

Frequently Asked Questions
Why do matching-looking numbers return different IF results?
Excel compares underlying values, not just the displayed digits. Calculated numbers can differ beyond the visible decimal places; use Home > Increase Decimal to inspect them or ROUND both values before comparing.
How many decimal places should I use in ROUND?
Use the precision required by your data. For example, use ROUND(A1,2) and ROUND(B1,2) when comparing amounts to two decimal places.
Why should I use 0 instead of "0" in the formula?
In =IF(ROUND(A1,9)=ROUND(B1,9),"-",0), 0 returns a number, while "0" returns text. Use the numeric result if you need to use it in calculations.
What if rounding does not fix the comparison?
Check whether the cells contain numbers or text by entering =ISNUMBER(A1) and =ISNUMBER(B1) in empty cells. If a value is stored as text, convert it to a number when appropriate, then compare again.




