The FILTER function returns every row of a range that meets the conditions you set, and the result updates automatically when the source data changes. Unlike the Filter button on the ribbon, it does not hide anything: it builds a separate, live list somewhere else on the sheet. This tutorial shows how to filter by one condition, by several conditions (AND and OR), how to show a message when nothing matches, and what changes between Excel and Google Sheets.
=FILTER(A2:D11, B2:B11="West", "No results"). In Google Sheets, use =FILTER(A2:D11, B2:B11="West") and wrap it in IFERROR if you want a custom message when nothing matches.The sample data
All examples use this small sales list in A1:D11. Order IDs are in column A, regions in B, sales reps in C and order amounts in D.
| Order | Region | Rep | Amount |
|---|---|---|---|
| SO-1001 | West | Maria | 420 |
| SO-1002 | East | Daniel | 880 |
| SO-1003 | West | Kevin | 1250 |
| SO-1004 | South | Aisha | 310 |
| SO-1005 | East | Maria | 640 |
| SO-1006 | West | Daniel | 560 |
| SO-1007 | South | Kevin | 975 |
| SO-1008 | West | Aisha | 290 |
| SO-1009 | East | Kevin | 1120 |
| SO-1010 | South | Maria | 705 |
FILTER syntax
In Excel the function has three arguments:
=FILTER(array, include, [if_empty])
- array – the range you want to return, for example A2:D11.
- include – a TRUE/FALSE test with the same number of rows as array, for example B2:B11="West".
- if_empty (optional) – what to show when no row passes the test.
FILTER is available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. Older versions such as Excel 2019 do not have it.
Example 1: Filter by one condition
To list every order from the West region, type this in an empty cell (F2, for example):
=FILTER(A2:D11, B2:B11="West")
The formula returns four rows: SO-1001, SO-1003, SO-1006 and SO-1008. You only type the formula in one cell; the results "spill" into the cells below and to the right. Headers are not included, so type them above the formula yourself if you need them.
To make the condition flexible, point it to a cell instead of typing the text: =FILTER(A2:D11, B2:B11=H1). Change H1 to "East" and the list updates.
Example 2: Multiple conditions with AND
To return West orders with an amount greater than 500, multiply the two tests:
=FILTER(A2:D11, (B2:B11="West")*(D2:D11>500))
This returns two rows: SO-1003 (1250) and SO-1006 (560), as shown in the screenshot above. SO-1001 (420) and SO-1008 (290) are West orders too, but they fail the amount test.
Example 3: Multiple conditions with OR
To return orders from the West or the South region, add the tests instead of multiplying them:
=FILTER(A2:D11, (B2:B11="West")+(B2:B11="South"))
This returns seven rows (SO-1001, 1003, 1004, 1006, 1007, 1008 and 1010), in the same order they appear in the source data.
Example 4: Show a message when nothing matches
There are no North orders in the data. Without the third argument, Excel returns a #CALC! error. Add if_empty to show a friendly message instead:
=FILTER(A2:D11, B2:B11="North", "No results")
The cell now shows "No results". You can also use an empty string ("") to leave the cell blank.
Example 5: Use FILTER inside other functions
Because FILTER returns an array, you can feed it into other functions. To total the West amounts:
=SUM(FILTER(D2:D11, B2:B11="West"))
The result is 2520 (420 + 1250 + 560 + 290), the same as =SUMIFS(D2:D11, B2:B11, "West"). To count how many orders are 900 or more, wrap FILTER in ROWS:
=ROWS(FILTER(A2:A11, D2:D11>=900))
That returns 3 (SO-1003, SO-1007 and SO-1009). For simple totals and counts, SUMIFS and COUNTIFS are shorter, but the FILTER approach is handy when you also want to see the matching rows.
FILTER in Google Sheets: what is different
Google Sheets has had FILTER for a long time, and the basic formula is the same:
=FILTER(A2:D11, B2:B11="West")
The main differences:
- Extra conditions can be separate arguments. In Sheets, each additional condition is treated as AND, so
=FILTER(A2:D11, B2:B11="West", D2:D11>500)returns the same two rows as Example 2. In Excel, the third argument is if_empty, so this form does not work there; use multiplication instead. - No if_empty argument. When nothing matches, Sheets returns an
#N/Aerror. Wrap the formula to show a message:
=IFERROR(FILTER(A2:D11, B2:B11="North"), "No results")
The + trick for OR conditions works in both programs.
How it works
A test like B2:B11="West" produces a list of ten TRUE/FALSE values, one per row. FILTER keeps the rows where the value is TRUE. When you multiply two lists, TRUE counts as 1 and FALSE as 0, so a row survives only if both tests are 1 (1×1=1); that is AND logic. When you add them, a row survives if at least one test is 1 (the sum is 1 or more); that is OR logic. Any non-zero number counts as "include".
Common mistakes
- Ranges of different sizes. array and include must cover the same rows.
=FILTER(A2:D11, B2:B10="West")returns an error because the test is one row short. - Blocked spill range. If any cell where the results need to go is not empty, Excel shows
#SPILL!(Google Sheets shows a#REF!error). Clear the cells below and to the right of the formula. - Using AND() or OR() inside FILTER.
AND(B2:B11="West", D2:D11>500)returns a single TRUE or FALSE for the whole range, not one per row. Use*and+instead. - Forgetting parentheses. Wrap each test in its own parentheses before multiplying or adding them, as in the examples above.
- Using commas for AND in Excel. That form only works in Google Sheets (see the section above).
FAQ
Can FILTER return only some columns?
Yes. Make array just the columns you need, for example =FILTER(C2:D11, B2:B11="West") to return only the rep and amount. The columns must be next to each other; for non-adjacent columns you need extra functions such as CHOOSECOLS in Excel.
Does FILTER update automatically?
Yes. When you change a value in the source range, the results recalculate immediately, which is the main advantage over the manual Filter button.
Why does my FILTER return #CALC! in Excel?
No row matched the condition and the formula has no if_empty argument. Add a third argument such as "No results".
Can I filter text that contains a word?
FILTER does not accept wildcards directly, but you can combine it with SEARCH: =FILTER(A2:D11, ISNUMBER(SEARCH("ar", C2:C11))) keeps rows where the rep name contains "ar". In the sample data only "Maria" matches, so it returns SO-1001, SO-1005 and SO-1010. SEARCH is not case-sensitive; use FIND if case matters.
Summary
FILTER returns all matching rows as a live list. Use one test for a single condition, multiply tests for AND, add them for OR, and use if_empty in Excel (or IFERROR in Google Sheets) to handle the case where nothing matches. If you only need a total or a count, conditional functions may be simpler; see our Math & Conditional Sums tutorials. For returning a single matching value instead of whole rows, browse the Lookup & Reference guides.
Comments
Post a Comment