How To Use The Excel FILTER Function - Exceljet
How To Use The Excel FILTER Function - Exceljet
Advertisement
Functions
FILTER Function
EXCEL 2021
DYNAMIC ARRAY
FILTER Function
Related functions
UNIQUE
FILTER
SORT
SORTBY
RANDARRAY
SEQUENCE
Summary
https://exceljet.net/functions/filter-function 1/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
The Excel FILTER function filters a range of data based on supplied criteria, and
extracts matching records.
Advertisement
Purpose
Return value
Arguments
Syntax
https://exceljet.net/functions/filter-function 2/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
Usage notes
The FILTER function "filters" a range of data based on supplied criteria. The result is
an array of matching values from the original range. In plain language, the FILTER
function will extract matching records from a set of data by applying one or more
logical tests. Logical tests are supplied as the include argument and can include many
kinds of formula criteria. For example, FILTER can match data in a certain year or
month, data that contains specific text, or values greater than a certain threshold.
The FILTER function takes three arguments: array, include, and if_empty. Array is
the range or array to filter. The include argument should consist of one or more logical
tests. These tests should return TRUE or FALSE based on the evaluation of values
from array. The last argument, if_empty, is the result to return when FILTER finds no
matching values. Typically this is a message like "No records found", but other values
can be returned as well. Supply an empty string ("") to display nothing.
The results from FILTER are dynamic. When values in the source data change, or the
source data array is resized, the results from FILTER will update automatically. Results
from FILTER will "spill" onto the worksheet into multiple cells.
Basic example
To extract rows in A1:C5 where the value in A1:A5 is greater than 100:
Notice the only difference in the above formulas is that the second formula provides a
multi-column range for array. The logical test used for the include argument is the
https://exceljet.net/functions/filter-function 3/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
same.
Since the value in H2 is "red", the FILTER function extracts data from array where the
Group column contains "red". All matching records are returned to the worksheet
starting from cell F5, where the formula exists.
Values can be hardcoded as well. The formula below has the same result as above
with "red" hardcoded into the criteria:
No matching data
https://exceljet.net/functions/filter-function 4/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
The value for is_empty is returned when FILTER does not find matching results. If a
value for if_empty is not provided, FILTER will return a #CALC! error if no matching
data is found:
To display nothing when no matching data is found, supply an empty string ("") for
if_empty:
To extract data based on a logical test for values that contain specific text, you can
use a formula like this:
= FILTER(rng1,ISNUMBER(SEARCH("txt",rng2)))
In this formula, the SEARCH function is used to look for "txt" in rng2, which would
typically be a column in rng1. The ISNUMBER function is used to convert the
result from SEARCH into TRUE or FALSE. Read a full explanation here.
Filter by date
FILTER can be used with dates by constructing logical tests appropriate for Excel
dates. For example, to extract records from rng1 where the date in rng2 is in July you
can use a generic formula like this:
https://exceljet.net/functions/filter-function 5/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
This formula relies on the MONTH function to compare the month of dates in rng2 to
7. See full explanation here.
The include argument can be extended with boolean logic. For example, to extract
only data where the group is "red" and score is greater than 80, you can use a formula
like this:
Complex criteria
To filter and extract data based on multiple complex criteria, you can use the FILTER
function with a chain of expressions that use boolean logic. For example, the generic
formula below filters based on three separate conditions: account begins with "x"
AND region is "east", and month is NOT April.
= FILTER(data,(LEFT(account) = "x") *
(region = "east") * NOT(MONTH(date) = 4))
See this page for a full explanation. Building criteria with logical expressions is an
elegant and flexible approach that can be extended to handle many complex
scenarios. See below for more examples.
Notes
https://exceljet.net/functions/filter-function 6/15
11/9/22, 2:53 AM How to use the Excel FILTER function | Exceljet
Advertisement
AUTHOR
Dave Bruns
Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you
work faster in Excel. We create short videos, and clear examples of formulas,
functions, pivot tables, conditional formatting, and charts.
Related Information
https://exceljet.net/functions/filter-function 7/15