Sub topic 7
Choosing a Replacement Value: 0, Blank or Message
This chapter assumes you can write IFERROR and IFNA formulas, copy them with absolute and relative references, and use IF and VLOOKUP. It covers what you put in the second argument. That value is data your sheet then has to live with.
Why the replacement value matters
IFERROR(value, value_if_error) and IFNA(value, value_if_na) both return whatever you give them when the check fails. Beginners usually pick 0 or "" without thinking. Those two choices behave very differently in totals, averages, counts, charts and any formula that reads the cell later.
A replacement value answers one question: what should this cell mean when the calculation cannot produce a result? There are four common answers:
- "The true answer is zero."
- "There is no answer, so leave it out."
- "There is no answer, and a person should know."
- "There is no answer, but a later formula must still run."
Each answer maps to a different value.
Option 1: zero
=IFERROR(A2/B2, 0)Use zero only when zero is a true statement. For example, a product with no sales rows really has sold zero units. A lookup into a table of discounts might reasonably return a 0% discount when a customer has no discount entry.
Zero is a real number, so every numeric function counts it. That is its strength and its danger.
Suppose a conversion rate column holds 0.2, 0.4, an error where B2 is 0, and 0.6:
| Replacement | Cell content | AVERAGE of the four cells |
|---|---|---|
| `0` | number 0 | 0.3 (sum 1.2 over 4 cells) |
| `""` | empty text | 0.4 (sum 1.2 over 3 numbers) |
Neither average is wrong in itself. The zero version says the row converted at 0%. The blank version says the row has no rate and should not count. If the divisor was zero because no data was recorded, the zero version understates the average.
Zero also affects these functions:
COUNTcounts it.MINcan return it, so a minimum of 0 may come from a failed calculation instead of real data.- Charts plot it as a point on the axis.
- Division by it in another formula produces a new
#DIV/0!.
Option 2: empty string
=IFERROR(A2/B2, "")The cell looks blank, but it contains a text value of zero length. That is not the same as an empty cell. Several functions treat the two differently:
| Test or function | Truly empty cell | Cell containing `""` |
|---|---|---|
| `ISBLANK(A2)` | TRUE | FALSE |
| `A2=""` | TRUE | TRUE |
| `COUNTA` | not counted | counted |
| `COUNTBLANK` | counted | counted |
| `SUM`, `AVERAGE`, `COUNT` | ignored | ignored (text in a range) |
| `A2+1` | 1 | `#VALUE!` |
The last row causes most of the trouble. Functions that take a range, such as SUM and AVERAGE, skip text. Direct arithmetic with the cell does not skip it. If column C contains "" for failed rows, this formula fails on those rows:
=C2*100You have three ways to handle that:
- Test first:
=IF(C2="", "", C2*100). - Convert text to zero:
=N(C2)*100.Nreturns 0 for text, so this treats the blank as zero. Only do that if zero is acceptable. - Avoid creating text in the first place by using a different replacement (see option 4).
Check ISBLANK usage too. If another formula or a data validation rule tests ISBLANK on a cell that holds "", it gets FALSE, which can be surprising.
Pasting as values makes it worse. The pasted cell keeps its zero-length text and still behaves as text, so it sorts after numbers and breaks later arithmetic. Clear the cell or run Find and Replace if you need true empties.
Option 3: a message
=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")A message is the most honest choice when a person needs to see that something is missing. It is also easy to count and filter:
=COUNTIF(F2:F100, "Not found")That formula gives a one-cell audit of how many lookups failed. A blank or a zero cannot give you that, because a blank looks the same as a legitimate blank, and a zero looks like real data.
A message is text, so it has the same arithmetic problem as "". If F2 holds "Not found" and G2 is =D2*F2, G2 returns #VALUE!. The error has moved one column to the right, and now it is harder to trace. You can stop the spread with a guard:
=IF(ISNUMBER(F2), D2*F2, "")ISNUMBER is a good guard because it accepts only real numbers and rejects text, blanks and errors.
Keep messages short and consistent. Use one wording such as "Not found" across the workbook, so your COUNTIF and conditional formatting rules can match it exactly. Add a conditional formatting rule that shades the message cells so they stand out in a long column.
Option 4: keep #N/A on purpose
Sometimes the best replacement for a chart or later calculation is the error itself, produced deliberately:
=IFERROR(A2/B2, NA())NA() returns #N/A. Line and scatter charts skip #N/A points instead of plotting them as zero, so the line has a gap or bridges over it. That is often better than a false drop to zero.
The cost is that SUM and AVERAGE over the range now return #N/A. You would need AGGREGATE with an option to ignore errors, for example =AGGREGATE(9, 6, C2:C100), where 9 means SUM and 6 means ignore error values. Use this pattern for chart-source columns. Do not use it for columns that feed totals.
Picking a value: a decision path
The diagram shows the order of questions to ask.
Treat the path as a starting point. A column that feeds a chart and also a total needs two columns: one that keeps a clean numeric result for totals, and one display or chart column derived from it.
A worked example
You have an order sheet. Column A holds product codes, column B holds units sold, and a price table sits in $H$2:$I$100. Your first attempt uses IFERROR everywhere with zero:
=IFERROR(VLOOKUP(A2, $H$2:$I$100, 2, FALSE), 0)Every unknown code now has a price of 0, and its revenue is 0. The monthly total looks plausible, and nobody notices the 14 products missing from the price table.
A better layout separates the lookup from the use of the result:
=IFNA(VLOOKUP(A2, $H$2:$I$100, 2, FALSE), "No price")Put that in column C, the unit price. Then compute revenue in column D:
=IF(ISNUMBER(C2), B2*C2, 0)Here the zero in D2 is a deliberate decision: an unpriced order contributes nothing to revenue yet. Finally, add a visible check cell:
=COUNTIF(C2:C500, "No price")The total still works, and the sheet reports how many rows it could not price. The message lives in the input column, where it is accurate. The zero lives in the output column, where it has a stated meaning.
Edge cases to watch
- Number formats can hide zeros without changing them. If you only want a blank look and still need a number, keep
0in the formula and format the cells with the custom format0.00;-0.00;;@. The empty third section hides zeros. This hides legitimate zeros as well, so use it only where that is acceptable. - Text sorts after numbers. A column with
""or messages in it sorts those rows to the bottom in ascending order, and they stay there in descending order too in some cases, so test before relying on a sort. - Lookup keys. If a column with
""is used as a lookup key, the value""can match other""cells. This produces matches you did not intend. - Type changes in dependent formulas.
=IF(C2="", ...)is TRUE for both a truly empty cell and a cell holding"".=C2=0is TRUE for an empty cell but FALSE for"". Know which one you wrote. - Dates. Zero in a date column displays as 1/0/1900 or 1900-01-00. Use a message or
"", not 0. - Percentages and averages. A zero rate may be false precision, as the conversion example showed. Prefer
""orNA()and let the average skip the row.
Replacement values do not fix the cause
A neat replacement can make a real error invisible. If IFERROR returns 0 for a #REF! caused by a deleted column, the sheet looks fine and the numbers are wrong. Choosing a message helps because a message makes the failure visible. Choosing a narrow handler helps more: use IFNA for lookups and an IF test for the divisor. Later chapters in this tutorial cover those checks in detail.
Summary table
| Replacement | Looks like | Numeric functions | Direct arithmetic | Best for |
|---|---|---|---|---|
| `0` | 0 | counted | works | true zero results |
| `""` | blank | ignored | `#VALUE!` | display-only columns |
| `"Not found"` | text | ignored | `#VALUE!` | lookups people must review |
| `NA()` | `#N/A` | `SUM` fails | `#N/A` | chart source columns |
Exercise
A column of conversion rates uses =IFERROR(A2/B2, 0). Rows where B2 is 0 mean "no visits recorded". The sheet's average rate looks too low. Explain why, and give a replacement formula that fixes it without making AVERAGE fail.
Show answer
The 0 is counted as a real 0% rate, so each no-visit row drags the average down. Return an empty string instead: =IFERROR(A2/B2, ""). AVERAGE ignores text in a range, so those rows drop out. A narrower option is =IF(B2=0, "", A2/B2), which handles only the zero divisor and leaves other errors visible.
Exercise
Column C contains =IFNA(VLOOKUP(A2, $H$2:$I$100, 2, FALSE), "No price") and column D contains =B2*C2. D shows #VALUE! for unknown products. Rewrite D2 so unpriced rows show a blank, and write a formula that counts the unpriced rows.
Show answer
Use =IF(ISNUMBER(C2), B2*C2, "") in D2. ISNUMBER is FALSE for the "No price" text, so the formula returns a blank instead of multiplying. Count the unpriced rows with =COUNTIF(C2:C500, "No price").