FILTER Condition Returns #N/A or the Wrong Rows
In Google Sheets, pointing FILTER at a text column returns #N/A, no matches found, not a type error. A number column can keep the wrong rows.
本文目錄
FILTER can spill the Ice 1 bookings you meant, or it can return #N/A with no matches, or keep the wrong rows, depending on what you put in the second argument. In these tests Sheets did not show a parameter-2 type error that says the function expects boolean values; a text condition simply behaved like FALSE.
Enter this fictional municipal ice-rink booking log in A1:E9. Put TRUE and FALSE in D2:D9 as real Boolean values (checkboxes are fine). Keep Minutes and Paid as numbers.
| Booking | Zone | Minutes | Confirmed | Paid |
|---|---|---|---|---|
| R-14 | Ice 1 | 60 | TRUE | 1 |
| R-15 | Ice 2 | 45 | FALSE | 0 |
| R-16 | Studio | 30 | TRUE | 1 |
| R-17 | Ice 1 | 90 | TRUE | 0 |
| R-18 | Ice 2 | 60 | FALSE | 1 |
| R-19 | Studio | 0 | FALSE | 0 |
| R-20 | Ice 1 | 45 | FALSE | 1 |
| R-21 | Ice 2 | 30 | TRUE | 1 |
To keep the Ice 1 bookings, enter this in G2:
=FILTER(A2:C9,B2:B9="Ice 1")
The formula spills three rows: R-14, R-17 與 R-20, with their zones and minutes.
The Zone column is not a condition
If you point parameter 2 at the Zone column itself:
=FILTER(A2:C9,B2:B9)
Sheets returns #N/A, with the message No matches are found in FILTER evaluation. That is easy to misread as “there are no Ice bookings,” but the column is full of zone names. Those names are text, and in this include array they behave like FALSE, so FILTER keeps no rows.
The hover uses a red Error heading and includes a Fix button; I did not click Fix. I did not get a message of the form “Function FILTER parameter 2 expects boolean values” on this text column, on a one-row text condition, or on an IF that returned zone labels. The failure is a quiet no-match, not a type error. Parameter 2 still needs an array of TRUE/FALSE values, one per row of A2:C9. The comparison B2:B9="Ice 1" produces that array: TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE. You can spill those eight values with =ARRAYFORMULA(B2:B9="Ice 1") if you want to inspect them first.
A lone label is a different problem. =FILTER(A2:C9,"Ice 1") returns #N/A with FILTER has mismatched range sizes. Expected row count: 8. column count: 1. Actual row count: 1, column count: 1. The literal is one cell, not eight conditions. That size error is covered in the FILTER mismatched range sizes guide.
Other values in parameter 2
These formulas all use the same booking range. The results below are from Google Sheets; do not assume a text or number column “just works” without checking what comes back.
| Formula | Result |
|---|---|
=FILTER(A2:C9,C2:C9) | Seven rows: every booking except R-19, whose Minutes value is 0. Nonzero numbers are treated as TRUE. |
=FILTER(A2:C9,D2:D9) | R-14, R-16, R-17 與 R-21. The Confirmed column is already Boolean. |
=FILTER(A2:C9,E2:E9) | R-14, R-16, R-18, R-20 與 R-21. The Paid flags 1 與 0 follow the same numeric rule as Minutes. |
=FILTER(A2:C9,SEARCH("Ice",B2:B9)) | The six Ice 1 and Ice 2 rows. SEARCH returns a position for those zones; on Studio it returns #VALUE! (In SEARCH evaluation, cannot find 'Ice' within 'Studio'.), and FILTER skipped that row rather than failing the whole formula. |
=FILTER(A2:C9,IF(B2:B9="Ice 1","Ice 1","Studio")) | #N/A, no matches. The IF returns zone text, which is treated like the raw Zone column. |
The text strings TRUE 與 FALSE (as text, not booleans) were coerced and returned the Ice 1 rows. Ordinary labels such as Ice 1 were not. I would not rely on that special-case coercion.
Write the comparison you mean
For a duration cutoff, compare the numbers:
=FILTER(A2:C9,C2:C9>=60)
That returns R-14, R-17 與 R-18. For payments, =FILTER(A2:C9,E2:E9=1) returns the five rows whose Paid value is 1. Both comparisons are easier to read than a bare column of numbers, and they do not depend on 0 happening to be the value you wanted to drop.
For a partial match, wrap SEARCH in ISNUMBER:
=FILTER(A2:C9,ISNUMBER(SEARCH("Ice",B2:B9)))
That also returns the six Ice bookings, and it stays FALSE on Studio instead of leaving a #VALUE! inside the include array. More text-search patterns are in FILTER wildcard and partial matches. If you need a list from a condition rather than a total, FILTER vs QUERY compares those two tools.
Google Sheets FILTER has no if_empty argument. A third argument is another condition, not a fallback message; empty results and Excel #CALC! belong on the CALC error page.
I would type the comparison (B2:B9="Ice 1", C2:C9>=60, or ISNUMBER(SEARCH(...))) and leave the source columns alone. If the include array already looks right in an ARRAYFORMULA helper and FILTER still errors, the next thing to check is range size, not a different zone spelling.
\n