New Tool Radar

AI for Data & Spreadsheets

How to Check What an AI-Written FILTER Formula Returns When Nothing Matches

Check what an AI-written FILTER formula returns when no rows match, and whether that empty result breaks the next step.

Schematic with three steps: Run the FILTER with a condition that; Add the if_empty argument; Check the downstream formula with the empty.

FILTER returns the rows that meet a condition, and when no rows meet it, the formula returns #CALC!, not an empty list. An AI-written formula that feeds FILTER into a SUM or a chart then breaks on the error, even though an empty result is a normal outcome for the data. Give FILTER an if_empty argument, or wrap it, before using its result downstream.

What you need

  • The AI-written FILTER formula
  • A test case where no rows match the condition
  • The formula or chart that uses the FILTER result

Step 1: Run the FILTER with a condition that matches nothing

Change the condition, in a copy, to a value that is not in the data, and read what the formula returns. A #CALC! error means no if_empty argument was supplied.

Step 2: Add the if_empty argument

Rewrite the formula with a third argument that says what to return when nothing matches, such as “No rows” for text or 0 when the result feeds a calculation.

Step 3: Check the downstream formula with the empty result

Run the formula that consumes the FILTER result, such as a SUM, with the empty case in place. It should return a sensible value, such as 0 or a message, instead of an error.

Worked example: synthetic region filter with no matches

The table below is a synthetic example. It shows the expected result of checking an AI-written FILTER formula; no formula was run.

Check Value Result
Condition tested Region = West No West rows in data
FILTER result as written #CALC! Error, not an empty list
if_empty added 0 Zero for the empty case
Downstream SUM 0 Returns zero instead of an error

Expected result (UNTESTED). the FILTER formula returns #CALC! when no West rows exist; adding 0 as the if_empty argument makes it return 0, and the downstream SUM then returns 0 instead of an error. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • FILTER needs Microsoft 365 or Excel 2021 or later; older versions show #NAME?.
  • An if_empty value of text breaks a downstream SUM, so match the if_empty type to how the result is used.
  • FILTER returns all matching rows at once, so a blocked cell in the spill range stops the whole result with #SPILL!.
  • A condition that compares text with numbers, such as “100” against 100, matches nothing even when the values look equal.

Sources

See all