The FILTER function in Google Sheets pulls out only the rows (or columns) of a range that meet your conditions. This guide covers a formula with two conditions, skipping blank rows, filtering columns instead of rows, and what to do about the #N/A you get when nothing matches.
The FILTER syntax Google documents
Google's FILTER help page gives the syntax as:
FILTER(range, condition1, [condition2, ...])
- range is the data you want filtered.
- condition1 is a column or row of TRUE/FALSE values that lines up with the first column or row of
range. It can also be an array formula that works out to TRUE/FALSE. - condition2, ... are optional extra conditions of the same kind.
Two rules from that page cause most broken formulas:
- Every condition must be the same length as
range. If your data runs A2:B26, your condition must also cover rows 2 to 26. - All conditions must be the same type. You can't mix a row condition with a column condition.
How to filter rows with two conditions
You add a second condition as another argument. There's no AND function wrapped around them. Google's own example:
=FILTER(A2:B26, A2:A26 > 5, D2:D26 < 10)
- Click an empty cell with plenty of empty space below and to the right of it. This is where the results will appear.
- Type
=FILTER(and select the data you want returned, hereA2:B26. - Type a comma and the first test,
A2:A26 > 5. - Type a comma and the second test,
D2:D26 < 10. - Close the bracket and press Enter.
The condition columns don't have to be inside range. In Google's example the formula returns columns A and B but tests column D. They only need to cover the same rows.
Google describes each condition as showing whether each row passes through, and its two-condition example implies a row has to pass both.
How to skip rows where a column is blank
Google's help page includes this sample for dropping rows where column A is empty:
=FILTER(A2:B10, NOT(ISBLANK(A2:A10)))
You can use this as one of your two conditions. For example, to keep only rows that have something in column A and a value above 5 in column B:
=FILTER(A2:B10, NOT(ISBLANK(A2:A10)), B2:B10 > 5)
Both conditions cover rows 2 to 10, matching the range.
How to filter columns instead of rows
FILTER also works sideways. Instead of a column of TRUE/FALSE values, give it a row that is as wide as your range. For a range B1:F20, which is five columns wide, a condition such as B2:F2 > 5 keeps only the columns whose value in row 2 is above 5:
=FILTER(B1:F20, B2:F2 > 5)
Google's page also shows that a condition can be a hard-coded array of TRUE/FALSE values, as in FILTER(A2:C5, {TRUE; TRUE; FALSE; TRUE}), which keeps the first, second and fourth rows.
Filtering rows and columns at once
One FILTER can handle rows or columns, not both. Google's note says to use the output of one FILTER as the range of another. For example, drop blank rows first, then keep only columns with a header:
=FILTER(FILTER(A2:F20, NOT(ISBLANK(A2:A20))), NOT(ISBLANK(A1:F1)))
The inner formula filters rows. The outer one uses a row condition, A1:F1, that is six columns wide to match A:F.
Why FILTER shows #N/A when nothing matches
This is expected behaviour. Google's help page says that if no values satisfy the conditions, FILTER returns #N/A. So a #N/A often means your formula is fine and nothing in the data passes the test.
Before changing the formula, check:
- Are the conditions too strict? Loosen one test, for instance
> 5to> 0, and see if rows appear. - Do the ranges line up? A condition that is a different length from
rangebreaks the formula. - Did you mix rows and columns? All conditions must be the same type.
Showing a message instead of #N/A
The Sheets version doesn't have one.
=IFERROR(FILTER(A2:B26, A2:A26 > 5, D2:D26 < 10), "No matches")
When a formula misbehaves, remove the wrapper first to see the real error. The same idea applies to lookups; our XLOOKUP guide for Google Sheets covers its own #N/A handling.
A related function: UNIQUE
The FILTER page's "See also" list points to UNIQUE, which you can use to drop repeated rows from the result. If you want to remove duplicates from the source data itself, see how to remove duplicates in Google Sheets.