Sub topic 12
Handling No Matches with IFERROR
Assume you can enter formulas in Google Sheets and understand cell references, ranges, and AVERAGEIFS. This chapter focuses on what happens when no row satisfies your conditions and how to present a useful result.
Why no matches matter
COUNTIFS and SUMIFS return 0 when no rows meet their criteria. AVERAGEIFS behaves differently. With no matching rows, it cannot divide a total by a count, so it returns the #DIV/0! error.
For example, this formula averages Revenue for the region named in G2:
=AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2)If G2 contains a region that does not appear in A2:A100, the result is #DIV/0!.
| Function | Result when no rows match |
|---|---|
| `COUNTIFS` | `0` |
| `SUMIFS` | `0` |
| `AVERAGEIFS` | `#DIV/0!` |
A zero and “no data” are different meanings. A zero may mean that matching rows exist but their values total zero. “No matches” means there were no qualifying rows.
Replacing the error with a message
IFERROR returns one value when a formula succeeds and another value when it produces an error. Wrap the complete AVERAGEIFS formula inside it:
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")The absolute references, $E$2:$E$100 and $A$2:$A$100, stay fixed when you fill the formula down. The reference G2 changes to G3, G4, and so on, so each row can use a different region.
You can return a numeric fallback instead:
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), 0)Use a numeric fallback only when later calculations should treat “no matches” as zero. Otherwise, a text label makes the missing result visible.
Choosing the right fallback
A summary table often combines a count, total, and average. Use COUNTIFS to show whether data exists, then use IFERROR for the average:
=COUNTIFS($A$2:$A$100, G2)=SUMIFS($E$2:$E$100, $A$2:$A$100, G2)=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")This makes the result easier to interpret. A count of 0 confirms that the average has no source rows.
Exercise
Exercise
Write a formula that averages values in E2:E100 for the region in G2 and displays "No matches" if the region has no rows.
Show answer
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")