Google Sheets FILTER Formula: Syntax, Examples, Excel Too
In Google Sheets, =FILTER(range, condition1, [condition2, ...]) returns only the rows of range where every condition is TRUE, for example =FILTER(A2:C7, B2:B7="Apples"). Excel's version is =FILTER(array, include, [if_empty]). Both spill the result into the cells below and to the right of the formula.
On this page▾
| Google Sheets | Excel | |
|---|---|---|
| Syntax | FILTER(range, condition1, [condition2, ...]) |
FILTER(array, include, [if_empty]) |
| Several conditions | Extra arguments | Multiply (AND) or add (OR) inside include |
| No rows match | #N/A |
#CALC! unless if_empty is given |
| Fix for no match | Wrap in IFNA(...) |
Use the third argument |
That makes it different from the Filter button on the Data tab, which hides rows in place. The formula result updates when the source changes and serves as a range for other formulas.
A sample table
The examples below use this small list, in A2:C7 with headers in row 1.
| Region | Product | Units |
|---|---|---|
| East | Apples | 30 |
| West | Apples | 12 |
| East | Pears | 18 |
| South | Apples | 25 |
| East | Apples | 41 |
| West | Pears | 9 |
One condition
To list every row where the product is Apples:
=FILTER(A2:C7, B2:B7="Apples")
The second argument is a column of TRUE and FALSE values, one per row. Microsoft describes it as a Boolean array whose height or width matches the array being filtered. Rows with TRUE come through. Here that is four rows: East 30, West 12, South 25 and East 41.
The condition range must be exactly as tall as the data range. Google's documentation states that condition arguments must have exactly the same length as the range. Keep the condition column the same size as the table, and extend both together when you add data.
How do I filter on two conditions (AND)?
In Excel, multiply two conditions to require both. Microsoft's example uses the multiplication operator for an AND:
=FILTER(A2:C7, (B2:B7="Apples")*(A2:A7="East"))
Only two rows pass: East Apples 30 and East Apples 41. A row needs a 1 from both tests to produce 1 in the product, so a single FALSE removes it.
In Google Sheets, extra conditions go in as additional arguments, for example =FILTER(A2:C7, B2:B7="Apples", A2:A7="East"). Each extra condition is another TRUE/FALSE column.
How do I filter on either condition (OR)?
In Excel, add the conditions instead of multiplying them. Microsoft's example for OR uses the addition operator:
=FILTER(A2:C7, (B2:B7="Apples")+(A2:A7="East"))
A row passes if either test is TRUE, so the sum is 1 or 2. Five of the six rows come back: all four Apples rows plus East Pears. Only West Pears is dropped, because it is neither Apples nor East. That is five rows, against two for the AND version, which is the quickest way to check you picked the right operator.
Filtering numbers instead of text
To return rows with at least 25 units, use:
=FILTER(A2:C7, C2:C7>=25)
The result is East Apples 30, South Apples 25, and East Apples 41: three rows. The comparison includes 25 itself. Changing the condition to C2:C7>25 removes the South row and leaves two rows. The returned range still includes Region and Product because A2:C7, not just the Units column, is the first argument.
Sorting the result
Wrap FILTER in SORT to order what comes back. Microsoft shows this form, where the number is the column to sort by and -1 means descending:
=SORT(FILTER(A2:C7, (B2:B7="Apples")*(A2:A7="East")), 3, -1)
The two East Apples rows come back as 41 first, then 30. For the OR version the five rows sort as 41, 30, 25, 18, 12.
Pulling a list of distinct values instead is covered in Get Unique Values From a Column in Excel With UNIQUE.
Why does FILTER show #N/A or #CALC!?
Excel and Google Sheets return different errors when no rows match.
- Excel returns a #CALC! error when no rows match, because it does not support empty arrays. The third argument fixes that:
=FILTER(A2:C7, B2:B7="Grapes", "No matches")shows the text instead. - Google Sheets returns #N/A when no values satisfy the conditions. There is no third argument for this, so wrap the formula:
=IFNA(FILTER(A2:C7, B2:B7="Grapes"), "No matches").
IFERROR catches all error types, while IFNA catches only #N/A. A #N/A fallback can still hide other #N/A errors, so check the condition ranges before treating that message as proof that no rows matched.
Spilling
A FILTER result spills into neighboring cells. Excel's documentation says it creates the right-sized array when you press Enter, so keep the area below and beside the formula free for the result.
If the source data is an Excel table and you use structured references, the result resizes as rows are added or removed. Microsoft also notes that dynamic arrays between workbooks only work while both files are open; close the source file and the linked formula returns #REF! on refresh.
Google adds one more rule: FILTER works on either rows or columns at one time. To filter both, use the output of one FILTER as the range of another.
When to use something else
If you only need a total for a condition, SUMIFS or COUNTIFS return one number without building a list. Use FILTER when you need the matching rows themselves, for a summary tab, a picklist, or a printout for one region.
Frequently asked questions
Why does a third argument copied from Excel fail in Google Sheets?
The argument positions mean different things. In Excel, the third argument is the optional no-result value. In Sheets, it is another condition, so "No matches" is not an Excel-style fallback there. Use IFNA(FILTER(...), "No matches") for the Sheets no-match case.
Can the conditions filter rows and columns at the same time? Not in a single Sheets FILTER call. All conditions must be row conditions or all must be column conditions. To filter both dimensions, use one FILTER result as the range for another FILTER.
What to check when the output is wrong
| Symptom | Check |
|---|---|
| Too many or too few rows | AND requires both tests; OR accepts either test |
| A boundary value is missing | >25 excludes 25; >=25 includes it |
| Sheets condition-length problem | Each condition must match the corresponding range length |
Excel error even with if_empty |
An error in include can propagate; the fallback handles no results, not every formula error |
Before changing the formula, compare the source rows with the expected matches. For the sample above, Apples gives four rows, Apples AND East gives two, and Apples OR East gives five. Check that source and condition ranges grow together when you add rows.
Sources
About this guide
Howlane operator · Checked against the official sources listed above. It is general information, not professional advice.
AboutEditorial standardsCorrectionsReport an error
Edit history
- Updated
- Updated
- Updated
- Updated
- Published