FILTER

Short answer

Pull every row that meets a condition, live

FILTER(array, include, [if_empty])
Excel version
2021+
Also searched as
extract rows that meet criteria, dynamic filter, return all matches, list unmapped accounts, filter with multiple criteria, lookup multiple values

What it returns

FILTER returns every row of array where include is TRUE. All matching rows, in source order, spilled into the cells below and to the right of the formula. Change the source and the result resizes on the next calculation.

That is the difference from XLOOKUP. A lookup returns one row, the first match. FILTER returns all of them. When the question is “which rows”, not “what value”, FILTER is the function.

When nothing matches, FILTER returns #CALC! unless you supply if_empty. On a check tab, an empty exception list is good news. A #CALC! error tells the reviewer the opposite.

Video: the FILTER Short on YouTube shows the core pattern in under a minute.

Arguments that matter

ArgumentRequiredWhat it does
arrayYesThe rows to return. TB[[Code]:[Amount]] returns three columns. A single column returns a list.
includeYesA TRUE/FALSE test with one result per row of array. TB[Line]="UNMAPPED". Must be the same height as array.
if_emptyNoWhat to show when no rows qualify. "None" or "No exceptions". Skip it and you get #CALC!.

include carries the logic, and combining conditions has its own syntax.

  • AND: multiply the tests. (GL[Entity]="UK")*(GL[Amount]>10000) keeps rows where both are true.
  • OR: add them. (GL[Code]=6100)+(GL[Code]=6200) keeps rows where either is true.
  • Each test sits in its own parentheses. Without them, operator precedence mangles the comparison.

The AND and OR worksheet functions do not work here. They collapse the whole column into one TRUE or FALSE, not one per row.

In a financial model

FILTER builds lists that stay current: exception reports, drill-downs, review queues. Anything an analyst used to produce with AutoFilter, copy, paste values, every month.

The highest-value use is on the check tab. A count tells you something is wrong. A FILTER tells you which rows. Put both side by side, per build a check row and make it loud: the count goes in the check row, the list sits beneath it for whoever has to fix it.

Typical lists in a model:

  • Trial balance codes with no mapping, from the "UNMAPPED" flag your XLOOKUP writes per one mapping table per dimension.
  • Account codes that break the chart-of-accounts format, with REGEXTEST in the include argument: NOT(REGEXTEST(TB[Code], "^[1-8]\d{3}$")).
  • Ledger lines over a materiality threshold for the month, for the flux review.
  • Every invoice for one customer, driven from a dropdown, for a deal drill-down.
  • Journals posted after the close date.

FILTER reads the raw extract and never edits it, in line with raw data stays raw.

Worked example

A trial balance on tab TB, formatted as a Table with columns Code, Name, Amount, Line. The Line column is filled by XLOOKUP([@Code], Map[Code], Map[Line], "UNMAPPED"). On tab Checks, the count sits in C4 and the list starts in B7.

The list of unmapped accounts:

=FILTER(TB[[Code]:[Amount]], TB[Line]="UNMAPPED", "None")
CodeNameAmountLine
4000Product revenue(812,400)Revenue
6115Cloud hosting18,250UNMAPPED
6120Software subs9,730Opex: IT
7410FX revaluation(2,115)UNMAPPED

Returns:

CodeNameAmount
6115Cloud hosting18,250
7410FX revaluation(2,115)

Map 6115 and 7410 and the list collapses to “None”.

A drill-down for the flux review. The vendor is picked in $C$3 and the month-end in $C$4:

=FILTER(GL[[Date]:[Amount]], (GL[Vendor]=$C$3)*(GL[Date]>=EOMONTH($C$4,-1)+1)*(GL[Date]<$C$4+1), "No rows")

Three conditions multiplied, so all three must hold. The date bounds run from the first of the month to strictly before the day after the month-end, which holds even when the dates carry times.

Old way vs new way

Before dynamic arrays, the formula version of this list was an array formula, confirmed with Ctrl+Shift+Enter and filled down far enough to cover the worst month:

=IFERROR(INDEX(TB!$A$2:$A$500, SMALL(IF(TB!$D$2:$D$500="UNMAPPED", ROW(TB!$A$2:$A$500)-ROW(TB!$A$2)+1), ROWS($1:1))), "")

The new way:

=FILTER(TB[[Code]:[Amount]], TB[Line]="UNMAPPED", "None")

One cell, all columns, no guessing how many rows to fill. Most teams skipped the old formula and used AutoFilter plus copy-paste, which goes stale the moment the TB is reloaded.

Where it breaks

FILTER returns #CALC!. No rows met the condition and if_empty was left out. On an exception list that is the result you wanted, shown as an error. Fix: always supply if_empty, with text that reads as a pass: "None".

FILTER returns #SPILL!. Something sits in the cells the result needs: a note, a stray value, another formula’s output. Dense check tabs hit this as lists grow. Fix: give every FILTER a clear block below it, and put lists beneath each other only with room for the worst case, or side by side.

FILTER returns #VALUE!. include is a different height from array, usually a whole-column reference tested against a Table column. Fix: point both arguments at the same Table so they grow together.

FILTER returns everything or nothing with two conditions. The conditions were joined with AND() or OR(), which return one value for the whole range. Fix: multiply tests for AND, add them for OR, each in its own parentheses.

FILTER returns #SPILL! inside a Table. Tables do not accept spilled results. Fix: put FILTER outside the Table, on a plain range.

A total under the list misses rows. It sums a fixed range, such as B7:D20, and this month’s list is longer. Fix: reference the spill with the # operator, =SUM(INDEX(B7#,0,3)), which always covers the whole result. INDEX with a row of 0 returns the entire third column.

FILTER returns #NAME?. The file is open in Excel 2019 or earlier. Fix: there is no direct equivalent in older versions. If the list must survive there, keep a COUNTIFS check and use AutoFilter for the detail.

Related functions

  • XLOOKUP. One key in, one row out. Use it when you want the first match, FILTER when you want all of them.
  • SORTBY. Wrap FILTER in it to put the largest exceptions first on a flux review.
  • CHOOSECOLS. Trims a filtered extract to the columns the reviewer needs.
  • UNIQUE. Wrap FILTER in it to list distinct vendors or codes that meet a condition.
  • GROUPBY. When the reader needs totals by category, not the rows themselves. It has its own filter argument.
  • The play on build a check row and make it loud covers where the counts and lists belong.

All functions