What is the FILTER function?
=FILTER(array, include, [if_empty])FILTER returns only the rows of a range that meet a condition. Without touching the filter buttons, one formula gives you lists like "Seoul sales only" or "quantity of 20 or more".
The result is an array that spills down and across from the formula cell, and it updates when the source changes. Per Microsoft documentation, it is available in Excel 2021 and later and Microsoft 365.
Arguments
- array
- The range that holds the rows to return. Usually the data only, without the header.
- include
- A comparison on a range with the same number of rows, like A2:A9="Seoul". Each row becomes TRUE (keep) or FALSE (leave out). Join several conditions in parentheses with * (and) or + (or).
- if_empty
- Optional. The value to return when no rows match. If omitted, you get #CALC!.
FILTER examples
Example 1. One condition
=FILTER(A2:D9, A2:A9="Seoul")The 3 rows for the Seoul branch come back as they are.
Example 2. A number condition
=FILTER(A2:D9, C2:C9>=20)Only rows with a quantity of 20 or more.
Example 3. Both conditions (and)
=FILTER(A2:D9, (A2:A9="Seoul")*(C2:C9>=20))Seoul rows with a quantity of 20 or more. Multiply the conditions in parentheses.
Example 4. Either condition (or)
=FILTER(A2:D9, (A2:A9="Seoul")+(A2:A9="Busan"))Rows for Seoul or Busan. Add the conditions in parentheses.
Example 5. if_empty value
=FILTER(A2:D9, A2:A9="Jeju", "None")There is no Jeju branch, so you get "None" instead of #CALC!.
Example 6. Filter, then sort
=SORT(FILTER(A2:D9, A2:A9="Seoul"), 4, -1)The Seoul rows sorted by the 4th column (Sales), largest first.
Common mistakes
#CALC! when nothing matches
An empty result cannot be returned, so FILTER gives #CALC!. If the result might be empty, add the third argument.
Include range of a different size
If the array is A2:D9, the include range must also cover rows 2 to 9. Otherwise you get #VALUE!.
Using AND or OR
AND(A2:A9="Seoul", C2:C9>=20) collapses the whole range into a single TRUE or FALSE. Use * and + to test row by row.
The spill range is blocked
If cells the result would spill into already hold values, you get #SPILL!. Clear those cells.
Wildcards
A2:A9="S*" compares the * literally. For rows starting with "S", use LEFT(A2:A9,1)="S".
FAQ
- How do I include the header?
- FILTER returns data rows only. Type the header in the cells just above the result.
- How do I return only some columns?
- Set the array to just those columns. For example, =FILTER(B2:B9, A2:A9="Seoul") returns product names only.
- What if I add rows to the source?
- Only rows inside the range are used. Turn the data into a table (Ctrl+T) and refer to it by name so new rows are included.
- What about older Excel?
- The supported versions in Microsoft documentation start at Excel 2021.