Sub topic 11
Common errors and handling them with IFERROR
This chapter assumes you can enter formulas in Google Sheets, read cell addresses such as B2, and write SUM, AVERAGE, COUNT, MIN, and MAX over a range. It also assumes you know that these functions skip text and blank cells. Here you will learn which errors the aggregate functions produce, why they appear, and how to handle them with IFERROR without hiding real problems.
What an error value is
When Google Sheets cannot compute a formula, it shows an error value in the cell instead of a number. An error value is a special result that starts with #, such as #DIV/0!. An error is different from a wrong answer. A wrong answer looks like a normal number, while an error is a clear signal that something needs attention.
Errors also spread. If one cell in a range holds an error, any aggregate that reads that cell returns the same error. This means one bad cell can break a whole report.
The errors you will meet
| Error | Typical cause with aggregates | Typical fix |
|---|---|---|
| `#DIV/0!` | AVERAGE over a range with no numbers, or a division by zero | Check the range, or wrap in IFERROR |
| `#VALUE!` | A function receives an argument of the wrong type | Correct the input |
| `#REF!` | A referenced cell or range was deleted | Rewrite the reference |
| `#NAME?` | A misspelled function name, such as `=SUMM(B2:B6)` | Fix the spelling |
| `#N/A` | A lookup found nothing, and a cell in your range holds that result | Fix the source cell |
| `#ERROR!` | The formula cannot be parsed, such as a missing parenthesis | Fix the syntax |
You will see #DIV/0! most often with the functions in this tutorial, so most of the examples below use it.
How one error cell breaks an aggregate
Suppose column B holds these values:
| Cell | Value |
|---|---|
| B2 | 10 |
| B3 | 20 |
| B4 | `#N/A` |
| B5 | 40 |
| B6 | 50 |
The next formula returns #N/A, not 120:
=SUM(B2:B6)The same happens with AVERAGE, MIN, and MAX. COUNT is an exception. It counts only cells that hold numbers, and an error cell is not a number, so =COUNT(B2:B6) returns 4. Compare this with COUNTA, which counts any non-empty cell and therefore includes the error cell, giving 5.
The rule to remember: SUM, AVERAGE, MIN, and MAX pass errors through, while COUNT skips them.
Why AVERAGE gives #DIV/0!
AVERAGE adds the numbers in the range, then divides by how many numbers it found. That count is the same value COUNT would return. If the range holds no numbers, the count is zero and the division fails.
This happens in three common situations:
- The range is completely empty, for example a new month with no data yet.
- The range holds only text, such as a column of labels.
- The range holds numbers stored as text, which AVERAGE ignores. A value that is left-aligned and has a small green or apostrophe marker in the cell is often text.
You can confirm the cause by checking the count:
=COUNT(B2:B6)If this returns 0, AVERAGE has nothing to work with. If it returns a number lower than you expect, some values are stored as text.
Note that SUM, MIN, and MAX do not show #DIV/0! on an empty range. SUM returns 0, and MIN and MAX also return 0. That quiet zero can mislead you, because it looks like a real result.
Handling errors with IFERROR
IFERROR takes two arguments. The first is the formula to try. The second is the value to show if the first produces any error.
=IFERROR(AVERAGE(B2:B6), "No data")If AVERAGE works, you see the average. If AVERAGE returns an error, you see the text No data.
The second argument can be text, a number, or an empty string. Choose it with care:
| Fallback | Formula | Effect |
|---|---|---|
| Text message | `=IFERROR(AVERAGE(B2:B6), "No data")` | Easy to read, but text in the cell will be skipped by later aggregates |
| Zero | `=IFERROR(AVERAGE(B2:B6), 0)` | Keeps the cell numeric, but 0 may be mistaken for a real average |
| Empty string | `=IFERROR(AVERAGE(B2:B6), "")` | Looks blank, but the cell is not truly empty |
If other formulas read this cell, a text fallback is safer than 0. A downstream AVERAGE will skip the text, while a 0 would pull the average down.
A complete worked example
Say a small sheet tracks daily sales for three stores, and one store has not reported yet.
| Row | A | B | C |
|---|---|---|---|
| 1 | Store | Week 1 | Week 2 |
| 2 | North | 120 | 135 |
| 3 | South | 98 | 102 |
| 4 | East |
Column D shows each store's average with protection against empty rows:
=IFERROR(AVERAGE(B2:C2), "Not reported")Fill this down from D2 to D4. D2 shows 127.5, D3 shows 100, and D4 shows Not reported, because row 4 holds no numbers and AVERAGE would otherwise return #DIV/0!.
The overall average then ignores the text in D4:
=AVERAGE(D2:D4)This returns 113.75, the mean of 127.5 and 100.
IFERROR can hide real problems
IFERROR catches every error type, not only #DIV/0!. This is a risk. Consider:
=IFERROR(SUMM(B2:B6), 0)The function name is misspelled, which produces #NAME?. IFERROR converts it into 0, and the sheet looks fine while the formula is broken. The same thing happens when a #REF! appears after someone deletes a column.
Follow these habits to avoid silent failures:
- Wrap only the part that can legitimately fail, and test the unwrapped formula first.
- Use a fallback that stands out, such as
"Check data", rather than 0. - Do not wrap a whole sheet's worth of formulas by default. Add IFERROR where you expect a specific, harmless error.
- When a result looks suspiciously like 0 or blank, temporarily remove IFERROR to see the real error.
Avoiding the error instead of hiding it
Sometimes a condition check is clearer than IFERROR. For an average that should appear only when numbers exist, you can test the count first:
=IF(COUNT(B2:B6)=0, "No data", AVERAGE(B2:B6))This catches only the empty case. A #N/A in the range would still pass through to AVERAGE and show as an error, which is often what you want, because it still alerts you to a real problem.
| Approach | Catches empty range | Catches other errors |
|---|---|---|
| `=IFERROR(AVERAGE(B2:B6), "No data")` | Yes | Yes, which may hide problems |
| `=IF(COUNT(B2:B6)=0, "No data", AVERAGE(B2:B6))` | Yes | No, so real errors remain visible |
Pick IFERROR for quick, low-risk reports. Pick the IF test when accuracy matters and you want unexpected errors to stay visible.
Finding the source of an error
When an aggregate shows an error, work backward:
- Click the cell and read the formula in the formula bar.
- Hover over the red marker or error cell to read Sheets' short explanation.
- Check each cell in the range for an error value. Sort or filter the column to bring error cells together.
- Check that numbers are real numbers. Use
=COUNT(B2:B6)against=COUNTA(B2:B6). If COUNTA is higher, some cells hold text or errors. - Evaluate smaller parts of the formula by testing them in an empty cell.
Common mistakes
- Wrapping a formula in IFERROR before checking that it works.
- Using 0 as the fallback in a cell that other averages will read.
- Assuming a blank-looking cell is empty when it holds an empty string from a previous IFERROR.
- Expecting COUNT to flag errors. It skips them silently.
- Fixing
#DIV/0!by editing AVERAGE when the real cause is numbers stored as text.
Exercise
Column B has the values 5, 15, and #N/A, then two blank cells (B2:B6, in that order). What do =SUM(B2:B6), =COUNT(B2:B6), and =IFERROR(SUM(B2:B6), "Check data") return?
Show answer
=SUM(B2:B6) returns #N/A, because SUM passes an error cell through. =COUNT(B2:B6) returns 2, because it counts only the two numbers and skips the error and the blanks. =IFERROR(SUM(B2:B6), "Check data") returns the text "Check data", because the SUM produces an error and IFERROR substitutes the fallback.
Exercise
A cell contains =IFERROR(AVERAGE(D2:D10), 0) and shows 0 although the data has not been entered yet. Why can this cause a problem in a report, and what would you change?
Show answer
The 0 looks like a real average, and any formula that reads this cell will treat it as a number, which can pull totals or averages down. Replace the fallback with text such as "No data", or use =IF(COUNT(D2:D10)=0, "No data", AVERAGE(D2:D10)) so only the empty case is handled and other errors stay visible.