Skip to content

FILTER

Returns only the rows (or columns) of a range that meet a condition. The result spills into the cells below and to the right.

Syntax

=FILTER(, , )

Dynamic arrays

Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. Not available in Excel 2019 or earlier.

Try it

Edit the formula in F2 or change the inputs. The sheet recalculates as you type.

F2
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1,200
SO-1001
North
Paid
1,200
3
SO-1002
South
Open
450
SO-1003
North
Open
980
4
SO-1003
North
Open
980
SO-1006
North
Paid
640
5
SO-1004
East
Paid
1,530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2,100

F2 =FILTER(A2:D9,B2:B9="North") returns SO-1001, North, Paid, 1200; SO-1003, North, Open, 980; SO-1006, North, Paid, 640

How FILTER works

FILTER pulls the rows you want out of a table with a single formula. Point it at the table, give it a test, and it returns every row where the test is TRUE. When the data changes, the result changes with it.

The three arguments

  • array is the data to return. It can be several columns wide, and you get all of them back.
  • include is a test that produces one TRUE or FALSE per row, such as B2:B9="North" or D2:D9>=1000. It must have the same number of rows as array. The test works on whole columns at once, so you don't fill the formula down.
  • if_empty is what to show when nothing passes. Without it, an empty result is #CALC!.

AND and OR

To keep rows that meet two conditions, multiply the tests: (B2:B9="North")*(D2:D9>=700). Each TRUE counts as 1 and each FALSE as 0, so the product is 1 only when both are TRUE. To keep rows that meet either condition, add the tests: (B2:B9="East")+(B2:B9="West"). Any result above 0 counts as TRUE.

How spilling works

FILTER returns many cells from one formula. Excel puts the formula in the cell you typed it into, the anchor, and fills the cells below and to the right with the rest of the result. Those cells belong to the formula: you can't type in them, and they shrink or grow when the number of matches changes. The outlined block is the spill range.

If any cell in that block already holds something, Excel returns #SPILL! in the anchor and fills nothing. Clear the blocking cell, or move the formula, and the result appears. Merged cells and Excel tables also block a spill, because a table can't contain a dynamic array formula.

To refer to a whole spill range from another formula, add # after the anchor cell: =SUM(F2#) or =ROWS(F2#). The # follows the spill as it changes size, so you never need to adjust the range.

What FILTER doesn't do

FILTER doesn't sort. Wrap it in SORT, as in =SORT(FILTER(...),4,-1), when order matters. It has no wildcard matching: "No*" is read as literal text. To match part of a word, test with ISNUMBER(SEARCH("tape",C2:C9)). Text comparisons ignore case.

FILTER also replaces a lot of older work. Where you once needed an advanced filter, a helper column or an INDEX/SMALL array formula, one FILTER formula now does it, and it stays live. The trade-off is compatibility: Excel 2019 and earlier show #NAME?.

Arguments

array
The range or array to filter, such as A2:D9. Include every column you want back, not only the column you test.
include
A TRUE/FALSE test with one answer per row of array, such as B2:B9="North". Rows where the test is TRUE are kept. To filter columns instead of rows, give one answer per column.
if_emptyoptional
What to return when no row passes, such as "None found". If you leave it out and nothing matches, FILTER returns #CALC!.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Return every row for one region

F2 =FILTER(A2:D9,B2:B9="North")

Result: SO-1001, North, Paid, 1200; SO-1003, North, Open, 980; SO-1006, North, Paid, 640

Three orders are for the North, so the formula in F2 fills F2:I4. You only typed it in F2.

F2
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1,200
SO-1001
North
Paid
1,200
3
SO-1002
South
Open
450
SO-1003
North
Open
980
4
SO-1003
North
Open
980
SO-1006
North
Paid
640
5
SO-1004
East
Paid
1,530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2,100

F2 =FILTER(A2:D9,B2:B9="North") returns SO-1001, North, Paid, 1200; SO-1003, North, Open, 980; SO-1006, North, Paid, 640

Example 2

AND: two conditions at once

F2 =FILTER(A2:D9,(B2:B9="North")*(D2:D9>=700))

Result: SO-1001, North, Paid, 1200; SO-1003, North, Open, 980

Multiplying the tests keeps a row only when both are TRUE. SO-1006 is a North order, but at 640 it falls below 700.

F2
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1200
SO-1001
North
Paid
1200
3
SO-1002
South
Open
450
SO-1003
North
Open
980
4
SO-1003
North
Open
980
5
SO-1004
East
Paid
1530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2100

F2 =FILTER(A2:D9,(B2:B9="North")*(D2:D9>=700)) returns SO-1001, North, Paid, 1200; SO-1003, North, Open, 980

Example 3

OR: either of two regions, one column back

F2 =FILTER(A2:A9,(B2:B9="East")+(B2:B9="West"))

Result: SO-1004; SO-1007; SO-1008

Adding the tests keeps a row when either is TRUE. Because array is only column A, only the order numbers come back.

F2
A
B
C
D
E
F
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1200
SO-1004
3
SO-1002
South
Open
450
SO-1007
4
SO-1003
North
Open
980
SO-1008
5
SO-1004
East
Paid
1530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2100

F2 =FILTER(A2:A9,(B2:B9="East")+(B2:B9="West")) returns SO-1004; SO-1007; SO-1008

Example 4

Show a message when nothing matches

F2 =FILTER(A2:D9,D2:D9>5000,"No orders over 5,000")

Result: No orders over 5,000

No order is above 5,000. Without the third argument this would be #CALC!.

F2
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1200
No orders over 5,000
3
SO-1002
South
Open
450
4
SO-1003
North
Open
980
5
SO-1004
East
Paid
1530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2100

F2 =FILTER(A2:D9,D2:D9>5000,"No orders over 5,000") returns No orders over 5,000

Example 5

Blocked spill: #SPILL!

F2 =FILTER(A2:D9,B2:B9="North")

Result: #SPILL!

The result needs F2:I4, but H3 already holds text. Excel shows #SPILL! until H3 is cleared. The error message on the cell names the blocking cell.

F2
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1200
#SPILL!
3
SO-1002
South
Open
450
Check
4
SO-1003
North
Open
980
5
SO-1004
East
Paid
1530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2100

F2 =FILTER(A2:D9,B2:B9="North") returns #SPILL!

Example 6

Use the spill range with #

F7 =SUM(INDEX(F2#,0,4))

Result: 2820

F2# means the whole spilled block from F2. INDEX(…,0,4) takes its fourth column, the amounts, and SUM adds them: 1,200 + 980 + 640.

F7
A
B
C
D
E
F
G
H
I
1
Order
Region
Status
Amount
2
SO-1001
North
Paid
1200
SO-1001
North
Paid
1200
3
SO-1002
South
Open
450
SO-1003
North
Open
980
4
SO-1003
North
Open
980
SO-1006
North
Paid
640
5
SO-1004
East
Paid
1530
6
SO-1005
South
Paid
760
7
SO-1006
North
Paid
640
2820
8
SO-1007
East
Open
310
9
SO-1008
West
Paid
2100

F7 =SUM(INDEX(F2#,0,4)) returns 2820

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 3

In E4, list every ticket (all three columns) for the team named in F1.

Answer in E4.

E4
A
B
C
D
E
F
G
1
Ticket
Team
Hours
Team
Billing
2
T-501
Billing
3
Min hours
4
3
T-502
Network
6
4
T-503
Access
2
5
T-504
Billing
5
6
T-505
Network
4
7
T-506
Billing
7
8
T-507
Access
1
9
T-508
Network
2
10
11
12
13
14
15
16
17
18

Common mistakes

  • #SPILL! means something is in the way. Look for a typed value, a formula or a merged cell inside the block where the result needs to go, and clear it. FILTER can't spill into an Excel table at all, so keep the formula outside the table.
  • #CALC! means no row passed the test and you gave no if_empty. Add a third argument such as "None" so the report shows a message instead of an error.
  • #VALUE! usually means the include test has a different number of rows than array, such as B2:B8 against A2:D9. Make both start and end on the same rows.
  • Don't use AND(...) or OR(...) inside include. They collapse the whole range to one TRUE or FALSE. Multiply tests for AND and add them for OR.
  • Empty cells in array come back as 0, not blank. Wrap the result in a test such as IF(result="","",result) if you need real blanks.

Questions people ask

Why does FILTER return #SPILL!?

The cells where the result should go are not empty. Clear the block below and to the right of the formula, or move the formula to clear space. Merged cells and Excel tables also cause it.

How do I filter on two conditions?

Multiply the tests for AND: `=FILTER(A2:D9,(B2:B9="North")*(D2:D9>=700))`. Add them for OR: `=FILTER(A2:D9,(B2:B9="East")+(B2:B9="West"))`. Put each test in its own brackets.

How do I sort the filtered results?

Wrap FILTER in SORT: `=SORT(FILTER(A2:D9,B2:B9="North"),4,-1)` returns the North orders with the largest amount first.

What is the # after a cell reference?

It is the spill range operator. If F2 holds a formula that spills, `F2#` refers to the whole block it fills, however large it is today. `=ROWS(F2#)` counts the matches.

Does FILTER work in older versions of Excel?

No. It needs Microsoft 365, Excel 2021 or later, or Excel for the web. In Excel 2019 and earlier the formula returns `#NAME?`.

Can FILTER return only some columns?

Yes. Either point `array` at just those columns, such as `A2:A9`, or wrap the result: `=CHOOSECOLS(FILTER(A2:D9,B2:B9="North"),1,4)` returns the order number and the amount.

Learn FILTER in a real sheet.

FILTER is taught in Data analysis with formulas, lesson 9: FILTER: pull out matching rows. Each lesson is a short, graded exercise like the one above.