Sub topic 7
Choosing a Replacement Value: 0, Blank or Message
This chapter assumes you can enter and copy formulas, use relative and absolute references, and write basic IF and VLOOKUP formulas. You also know how IFERROR and IFNA work. Here you will decide what they should return.
Three common choices
When a formula fails, the handler needs a replacement value. Each choice has a different meaning to the reader and a different effect on other formulas.
| Replacement | Example | Type of result | Typical use |
|---|---|---|---|
| 0 | `=IFERROR(A2/B2, 0)` | Number | The true answer is "none", and totals must keep working |
| Empty string | `=IFERROR(A2/B2, "")` | Text | A clean look in a report |
| Message | `=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")` | Text | The reader needs to know something is missing |
Using 0
Zero is a number, so SUM, AVERAGE and arithmetic accept it. Use it only when zero is a true answer. A division by zero with no sales might reasonably be 0%.
=IFERROR(A2/B2, 0)Zero can mislead. AVERAGE counts a 0 as a real value, so a made-up zero lowers the average. A missing price replaced by 0 can also make a product look free.
Using an empty string
An empty string looks blank, but it is text, not an empty cell.
=IFERROR(A2/B2, "")This causes several problems:
ISBLANKreturns FALSE for the cell.SUMandAVERAGEignore the text, which is often what you want.=C2*2returns #VALUE! when C2 holds"", because arithmetic operators cannot use text.COUNTAcounts the cell, whileCOUNTdoes not.
So the error has moved to the next formula. Plan for that. Either use functions that skip text, or test the cell before you use it.
Using a message
A message tells the reader why there is no number.
=IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), "Not found")Messages make problems easy to see and easy to search for. They behave like the empty string in calculations: SUM ignores them, but direct arithmetic gives #VALUE!. Keep messages short and consistent, so you can filter for them or count them with COUNTIF(range, "Not found").
Avoiding the problem first
Sometimes the cleanest option is to handle only the known case. This formula treats a zero divisor and leaves every other error visible:
=IF(B2=0, "", A2/B2)A related choice for lookups is to put the message inside XLOOKUP:
=XLOOKUP(E2, $A$2:$A$100, $B$2:$B$100, "Not found")Choosing with a decision path
A worked comparison
Suppose column C holds =IFNA(VLOOKUP(E2, $A$2:$B$100, 2, FALSE), x) and one product is missing from the list. Column D then computes =C2*10.
| Value of x | C2 result | D2 result | `SUM(C:C)` effect |
|---|---|---|---|
| 0 | 0 | 0 | Unchanged |
| "" | blank-looking text | #VALUE! | Ignored |
| "Not found" | text | #VALUE! | Ignored |
With 0, everything works, but the missing product is hidden inside the data. With text, the error is visible in column D, so you must guard it, for example =IF(ISNUMBER(C2), C2*10, "").
Common mistakes
- Using 0 when the truth is "unknown". Averages and totals then look more certain than they are.
- Using
""and forgetting that it is text. - Using different messages in different columns, which makes filtering hard.
- Wrapping a whole formula in IFERROR when the error is a mistake you should fix.
Exercise
Column B holds a lookup that returns a unit price, or "Not found" when the product is missing. Column C is =B2*D2 (price times quantity), and it shows #VALUE! for missing products. Rewrite C2 so it shows a blank for missing products and still multiplies for the others.
Show answer
Use ISNUMBER to test the price first: =IF(ISNUMBER(B2), B2*D2, ""). The arithmetic runs only when B2 is a number. Text such as "Not found" gets a blank instead of #VALUE!.
Exercise
Why can replacing a missing price with 0 be worse than replacing it with "Not found"?
Show answer
A 0 is a valid number, so totals, averages and later calculations accept it and the missing data goes unnoticed. The text message stays visible and flags the gap.