Sub topic 10
Filter with the FILTER function
This chapter assumes you can write simple formulas, read ranges such as A2:D100, and have used the Data menu filter. The FILTER function does the same job with a formula. It returns the rows that meet your conditions and leaves the source data alone. The result is live: when the source data changes, the result changes with it.
The working model
FILTER takes a range and one or more conditions. It returns the rows of the range for which every condition is TRUE.
=FILTER(range, condition1, [condition2, ...])Each condition is a column-shaped array of TRUE and FALSE values, one per row of range. A condition such as A2:A="West" is not a single comparison. Sheets compares every cell in A2:A to "West" and produces a column of results. FILTER keeps a row where the matching value is TRUE.
The examples in this chapter use this data. Row 1 holds the headers, and the data sits in A2:D7.
| Region | Rep | Amount | Order date |
|---|---|---|---|
| West | Ana | 1200 | 2026-01-15 |
| East | Ben | 800 | 2026-02-03 |
| West | Chen | 450 | 2026-02-10 |
| North | Dara | 1500 | 2026-03-01 |
| East | Eli | 2100 | 2026-03-12 |
| West | Fay | 1800 | 2026-03-20 |
Your first FILTER
To list every West row, put this formula in one cell, for example F2:
=FILTER(A2:D, A2:A="West")The formula returns three rows and four columns: Ana, Chen and Fay. Only F2 holds the formula. The other cells in the result are filled automatically. This behavior is called spilling, and the result is a spill range. You can't edit a spilled cell on its own. To change the output, edit the formula in F2.
Two details matter here:
- Text comparison with
=ignores case, so"west"and"West"both match. - The range starts at row 2, so the header row is not part of the data being tested. Include the header only if you want it treated as a data row.
Combine conditions
AND: list more conditions
Each extra argument is another condition, and a row must satisfy all of them.
=FILTER(A2:D, A2:A="West", C2:C>1000)This returns Ana (1200) and Fay (1800). Chen is West but has an amount of 450, so he is dropped.
OR: add the arrays
Separate arguments only ever mean AND. For OR, add the conditions inside one argument. TRUE counts as 1 and FALSE as 0, so a sum above 0 means at least one condition was true.
=FILTER(A2:D, (A2:A="West")+(A2:A="East"))This returns five rows, everything except North.
Mixing AND and OR
Use * for AND and + for OR inside a single condition, and use parentheses to set the order. To get North or East rows with an amount of at least 1000:
=FILTER(A2:D, ((A2:A="North")+(A2:A="East"))*(C2:C>=1000))The result is Dara (1500) and Eli (2100). Without the outer parentheses around the OR part, the multiplication would bind to only the East test, and you would get different rows.
NOT: use the opposite comparison
=FILTER(A2:D, A2:A<>"West")This returns every row whose region is not West.
Match part of a text value
The = operator tests the whole cell. To find cells that contain some text, use REGEXMATCH, which returns TRUE or FALSE for each cell in a range.
=FILTER(A2:D, REGEXMATCH(B2:B, "(?i)^(a|b)"))This keeps reps whose names start with A or B. The (?i) prefix makes the match case-insensitive, because REGEXMATCH is case-sensitive by default. If the cells might hold numbers, convert them first, for example with REGEXMATCH(TO_TEXT(B2:B), ...). Otherwise the numeric cells give errors.
Filter by date and by blanks
Compare dates with a real date value, not text. DATE builds one without any locale ambiguity.
=FILTER(A2:D, D2:D>=DATE(2026,3,1))This returns the March rows: Dara, Eli and Fay. It only works if column D contains true dates. Dates stored as text compare as text, so the filter returns wrong rows or none.
To skip blank rows when your range extends below the data, test for non-empty cells:
=FILTER(A2:D, A2:A<>"", C2:C>1000)Without A2:A<>"", a blank row can slip through some tests. For example, C2:C<1000 is TRUE for an empty cell, because Sheets treats an empty cell as 0 in a numeric comparison.
Return only some columns
The first argument does not have to be a contiguous block. Wrap separate columns in curly braces to build a new array, and FILTER will return only those columns. A comma inside braces joins columns side by side.
=FILTER({B2:B, C2:C}, A2:A="West")This returns rep and amount for West rows: Ana 1200, Chen 450 and Fay 1800. The braced array must be as tall as each condition, so use open-ended ranges that start on the same row.
Common errors
FILTER reports problems as error values. These are the ones you will meet most often.
| Error | Cause | Fix |
|---|---|---|
| `#N/A` with "No matches are found in FILTER evaluation" | No row met all conditions | Wrap the formula in IFERROR, or change the conditions |
| `#REF!` with "Array result was not expanded because it would overwrite data in..." | A non-empty cell sits in the spill range | Clear the cells in the way, or move the formula |
| `#VALUE!` with "FILTER has mismatched range sizes" | A condition has a different number of rows than the range | Make all ranges start and end on the same rows |
| Wrong rows returned | Numbers or dates stored as text | Convert them to real numbers or dates |
For the no-match case, this version shows your own message:
=IFERROR(FILTER(A2:D, A2:A="South"), "No matches")There is no South row in the sample data, so the cell shows "No matches". IFERROR hides every error, not only the no-match one. A typo in a range would also display "No matches". While you build a formula, test it without IFERROR first.
Size mismatches in detail
The mismatched-size error is the easiest to cause by accident. Both of these formulas fail:
=FILTER(A2:D7, A2:A="West")The range has six rows. The condition A2:A runs to the bottom of the sheet, which is many more than six rows. Match them by giving both the same end row, such as A2:D7 with A2:A7, or by leaving both open-ended. Open-ended ranges are convenient because new rows are included automatically.
FILTER or the Data menu filter
Choose by how the result will be used.
- Use the Data menu filter when you want to look at the same sheet in a narrower way and don't need the result elsewhere.
- Use FILTER when other formulas, charts or tabs depend on the subset, or when the subset must update as the data changes.
- FILTER results are formulas, not values. If you need a fixed snapshot, copy the result and use Paste special, then Values only.
The next chapter combines FILTER with SORT so the subset arrives in a chosen order.
Exercise
Write a formula for the sample data that returns all columns for rows where the Region is North or East and the Amount is at least 1000. Which reps appear in the result?
Show answer
=FILTER(A2:D, ((A2:A="North")+(A2:A="East"))*(C2:C>=1000)). The result contains Dara (North, 1500) and Eli (East, 2100). Ben is East but his amount of 800 is below 1000, so he is excluded.
Exercise
You enter =FILTER(A2:D, A2:A="West") in F2 and see #REF! saying the array result was not expanded. What is the most likely cause, and how do you fix it?
Show answer
A cell in the area where the result would spill, such as G3 or F4, already contains data. Clear the cells in the output area, or move the formula to a place with empty space below and to the right of it. The formula does not need to change.