What FILTER does
FILTER returns the rows of a range that meet a condition you set. The syntax is =FILTER(array, include, [if_empty]). The array is the data you want back. The include is a test that gives TRUE or FALSE for each row. The if_empty argument is optional, and it sets what to show when nothing matches.
FILTER works in Excel for Microsoft 365, Excel 2021 and Excel for the web. Excel 2019 doesn’t have it, and the formula shows #NAME? there.
A basic example
Suppose column A holds order dates, column B holds the region, and column C holds the sales amount. Row 1 has headers, and the data runs from row 2 to row 50. To list only the North rows, type this into an empty cell:
=FILTER(A2:C50, B2:B50=“North”)
Excel returns every row where column B says North, with all three columns. The result spills down from the formula cell, and it updates when the data changes.
Adding the headers yourself
FILTER returns only the matching data rows, not the header row. Type the headers, or copy them from row 1, into the row directly above the formula. That gives the list a title row.
Matching more than one condition
Use a multiplication sign (*) for AND and a plus sign (+) for OR. Wrap each condition in parentheses. Comparisons run after multiplication and addition, so without the parentheses the test won’t do what you expect.
To return rows where both conditions are true:
=FILTER(A2:C50, (B2:B50=“North”)*(C2:C50>500))
To return rows where either condition is true:
=FILTER(A2:C50, (B2:B50=“North”)+(B2:B50=“South”))
Filtering by a value in a cell
Typing “North” into the formula means editing the formula every time you want a different region. Put the region in a cell, such as F1, and point the formula at that cell instead:
=FILTER(A2:C50, B2:B50=F1)
Change the value in F1 and the list changes with it. A drop-down list in F1 (Data > Data Validation) makes it easy to switch regions.
Totals of the filtered rows
Wrap FILTER in SUM to total the amounts that match:
=SUM(FILTER(C2:C50, B2:B50=“North”))
If you only need the total for one condition, SUMIF gives the same answer in a simpler formula, with no spill. If you want to compare the two, how to use sumif in excel shows the single-condition version.
What to show when nothing matches
If no row meets the condition, FILTER returns #CALC!. To show a message instead, add a third argument:
=FILTER(A2:C50, B2:B50=“Midwest”, “No matching rows”)
The message appears in the formula cell as plain text.
Common errors
- #VALUE! means the include test and the array have different numbers of rows. For example, a test on B2:B40 can’t be used with A2:C50. Make both ranges cover the same rows. For the general fix, see how to fix #value error in excel.
- #CALC! means nothing matched and you didn’t add an if_empty message.
- #SPILL! means something sits in the cells the result needs. Clear those cells, and see how to fix #spill error in excel if the problem continues.
- #NAME? means your version of Excel doesn’t include FILTER.
If you already use IF
If you already know how to use if function in excel, the conditions here will look familiar. They use the same comparison operators, such as =, <> and >. The difference is that FILTER tests a whole column at once and returns every row that passes.
Google Sheets
Google Sheets also has FILTER, but it takes each condition as a separate argument. The AND example above looks like this in Sheets:
=FILTER(A2:C50, B2:B50=“North”, C2:C50>500)
Each condition after the range must be true for a row to be returned.