Excel function

FILTERfunction

Returns only the rows that meet a condition, spilled into several cells.

Excel 2021+
=FILTER(A2:D9, A2:A9="Seoul")
Range to drag
A
B
C
D
E
F
G
H
I
1
2
3
4
5
6
7
8
9

Drag the corner dots to change array, include range. Click a cell in the criteria range to use its value as the criteria. Click a cell in the table to filter on that column and value. Enter "Jeju" as the condition: nothing matches, so you get #CALC!. Fill in if_empty to return that value instead. Try breaking it on purpose to see the errors.

Result

{"Seoul","Apple",30,45000;"Seoul","Bread",8,25600;"Seoul","Milk",40,96000}

array
A2:D9Drag the corner dots on the table

The range that holds the rows to return.

include range
A2:A9

One column to test. It must have as many rows as the array.

condition

What to compare each value in the include range with, such as "Seoul" or ">=20".

if_empty

The value to return when no rows match. Leave it blank and you get #CALC!.

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

  1. Example 1. One condition

    =FILTER(A2:D9, A2:A9="Seoul")

    The 3 rows for the Seoul branch come back as they are.

  2. Example 2. A number condition

    =FILTER(A2:D9, C2:C9>=20)

    Only rows with a quantity of 20 or more.

  3. 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.

  4. Example 4. Either condition (or)

    =FILTER(A2:D9, (A2:A9="Seoul")+(A2:A9="Busan"))

    Rows for Seoul or Busan. Add the conditions in parentheses.

  5. Example 5. if_empty value

    =FILTER(A2:D9, A2:A9="Jeju", "None")

    There is no Jeju branch, so you get "None" instead of #CALC!.

  6. 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

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.