Sub topic 10
Handling empty results and #CALC!
This chapter assumes you can enter formulas, use ranges, and have used FILTER, SORT and UNIQUE in Excel for Microsoft 365 or Excel 2021 or later. It explains what happens when an array formula has nothing to return, and how to handle that case.
Why an empty array is an error
A spill range needs at least one cell of output. Some formulas legitimately find nothing. For example, a FILTER condition may match no rows. Excel has no way to show an array with zero cells, so it returns the #CALC! error in the anchor cell.
#CALC! means the calculation engine could not produce a usable array. The most common cause is an empty result from FILTER. Other causes exist, such as a LAMBDA function that returns an unsupported value, but empty arrays are the case you will meet first.
=FILTER(A2:C20,C2:C20>100)If no value in C2:C20 is above 100, this formula shows #CALC! in the cell where you entered it.
Supplying a fallback with if_empty
FILTER takes an optional third argument, if_empty. Excel shows this value when no rows match.
=FILTER(A2:C20,C2:C20>100,"No matches")When rows match, the formula spills them as usual. When none match, the single cell shows the text "No matches".
The fallback does not have to be text. You can return a blank, a zero, or a full-width row of blanks:
=FILTER(A2:C20,C2:C20>100,"")An empty string displays as a blank cell. It is still a value, so the cell is not truly empty. A formula that refers to it can treat it as text.
Where the fallback is not enough
The if_empty argument is built into FILTER only. Other functions can produce empty or invalid arrays inside a larger formula, and you must handle those yourself.
Suppose you sort the result of a FILTER:
=SORT(FILTER(A2:C20,C2:C20>100,"No matches"),3,-1)If nothing matches, FILTER returns the text "No matches", which is a single cell. SORT then tries to sort by column 3 of a one-column result. That fails with a different error (#VALUE!), not #CALC!. Handle the empty case once, outside the whole chain, so the later functions never receive the fallback.
=LET(rows,FILTER(A2:C20,C2:C20>100,0),IF(ROWS(rows)=0,"No matches",SORT(rows,3,-1)))This version has a problem of its own. With if_empty set to 0, FILTER returns a single cell holding 0, and ROWS(rows) is then 1, not 0. The check never fires. A more reliable pattern tests the condition directly:
=IF(COUNTIF(C2:C20,">100")=0,"No matches",SORT(FILTER(A2:C20,C2:C20>100),3,-1))Here COUNTIF decides whether there is anything to filter. The FILTER call only runs when at least one row qualifies.
Choosing a approach
| Situation | Approach |
|---|---|
| A single FILTER may match nothing | Use the `if_empty` argument |
| FILTER feeds SORT, TAKE or another function | Test with COUNTIF or similar first, then run the chain |
| The empty case should look blank | Return `""` as the fallback |
| You want to hide any error | Wrap in IFERROR, but only as a last resort |
IFERROR also catches #CALC!, but it hides every other error too. Typos and broken references then look like "no data". Prefer the targeted fallback.
How the pieces fit
Exercise
A cell contains =FILTER(A2:B10,B2:B10="Paid") and shows #CALC!. Name two ways to change the result so that it shows "None paid" when no rows match.
Show answer
Add the third argument: =FILTER(A2:B10,B2:B10="Paid","None paid"). Or test first with COUNTIF: =IF(COUNTIF(B2:B10,"Paid")=0,"None paid",FILTER(A2:B10,B2:B10="Paid")).
Exercise
Why is IFERROR a poor first choice for handling an empty FILTER result?
Show answer
IFERROR hides every error, not only #CALC!. A wrong range or a typo in the formula would also display as the fallback, so real problems go unnoticed.