Exceljet

Quick, clean, and to the point

Excel FILTER Function

Excel FILTER function
Summary 

The Excel FILTER function filters a range of data based on supplied criteria, and extracts matching records.

Purpose 
Filters range with given criteria
Return value 
Array of filtered values
Syntax 
=FILTER (array, include, [if_empty])
Arguments 
  • array - Range or array to filter.
  • include - Boolean array, supplied as criteria.
  • if_empty - [optional] Value to return when no results are returned.
Usage notes 

The Excel FILTER function "filters" a range of data based on supplied criteria. The result is an array of matching values the original range. When this array is the final result (i.e. the results are not handed off to another function) matching results will "spill" on to the worksheet. In simple language, the FILTER function allows you to easily extract mathing records from a larger set of source data based on criteria you provide.

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.

Example

In the example shown, the formula in F5 is:

=FILTER(B5:D14,D5:D14=H2,"No results")

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:

=FILTER(B5:D14,D5:D14="red","No results")

To return nothing when no matching data is found, supply an empty string ("") for if_empty:

=FILTER(B5:D14,D5:D14=H2,"")

More than one criteria

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:

=FILTER(B5:D14,(D5:D14="red")*(C5:C14>80),"No results")

Building criteria with logical expressions is an elegant and flexible approach. For more examples of the kind of criteria you can construct with boolean expressions, see examples on our SUMPRODUCT function page.

Notes

  1. Filter can work with both vertical and horizontal arrays.
  2. The include argument must have a dimension compatible with the array argument, otherwise filter will return #VALUE!
  3. If the include array includes any errors, FILTER will return an error.
  4. If FILTER is used between workbooks, both workbooks must be open, otherwise FILTER will return #REF!.
Note: The FILTER function is a new "Dynamic Array Function" in Excel. It is a beta feature available only through the Office Insiders program. Dynamic Array functions are expected to be released in 2019 to Office 365 subscribers.

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.