Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Excel PivotTables

Excel PivotTable Intro Excel Create PivotTable Excel PivotTable Values Excel PivotTable Filter Excel PivotTable Group Excel Calculated Field Excel PivotChart

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS DATEDIF FILTER HLOOKUP IF IFERROR IFS INDEX INDEX MATCH LEFT LEN LOWER MATCH MAX MEDIAN MID MIN MODE NETWORKDAYS NPV OR PROPER RAND RIGHT ROUND SORT STDEV.P STDEV.S SUBSTITUTE SUM SUMIF SUMIFS SUMPRODUCT TEXTJOIN TODAY TRIM UNIQUE UPPER VLOOKUP XLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Cert

Excel Certificate

Excel Examples

Excel Exercises Excel Syllabus Excel Study Plan Excel Training

Excel References

Excel Keyboard Shortcuts


Excel FILTER Function


Share

FILTER Function

The FILTER function is a premade function in Excel, which returns the rows of a range that meet one or more conditions.

The matching rows are placed where you type the formula. The original data is not changed.

This page is about the FILTER function, which you type in a cell. To hide rows with the Filter buttons in the header row, see the Excel Filter page.

It is typed =FILTER and has the following parts:

=FILTER(array, include, [if_empty])

Note: FILTER is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It is not available in Excel 2019 or earlier. If you type it in an older version, you get a #NAME? error.

Note: The different parts of the function are separated by a symbol, like comma , or semicolon ;

The symbol depends on your Language Settings.

Array: The range to filter, for example A2:E21. Leave out the header row.

Include: The condition. It is checked for every row, for example C2:C21="Fire". It must have the same number of rows as the array.

If_empty: Optional. The value to show if no rows meet the condition. If you leave it out and nothing matches, FILTER returns a #CALC! error.

How to use the FILTER function:

  1. Select a cell (G2)
  2. Type =FILTER
  3. Double click the FILTER command
  4. Mark the range to filter (A2:E21)
  5. Type (,)
  6. Mark the column to check (C2:C21)
  7. Type the condition (="Fire")
  8. Hit enter

Let's have a look at an example!

This is the same Pokemon table as on the XLOOKUP page. Copy it and paste it into cell A1 to follow along:

Example data

ABCDE
1ID#NameType 1Type 2Total
21BulbasaurGrassPoison318
32IvysaurGrassPoison405
43VenusaurGrassPoison525
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413

FILTER does not return the header row. Copy the headers in A1:E1 and paste them into G1.

Use the FILTER function to list all the Pokemon with Fire as Type 1. Type the formula in G2:

ABCDEFGHIJK
1ID#NameType 1Type 2TotalID#NameType 1Type 2Total
21BulbasaurGrassPoison3184CharmanderFire0309
32IvysaurGrassPoison4055CharmeleonFire0405
43VenusaurGrassPoison5256CharizardFireFlying534
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413
=FILTER(A2:E21, C2:C21="Fire")

FILTER checks C2:C21 row by row. Three rows have Fire: Charmander, Charmeleon and Charizard. FILTER returns these three rows, with all five columns.

The formula is typed only in G2. The result spills into G2:K4.

The result updates by itself. If you change the Type 1 of another Pokemon to Fire, it is added to the list.

Note: Empty cells in the array are returned as 0, not as empty cells. Charmander and Charmeleon have no Type 2, so J2 and J3 show 0.

Note: The cells that the result spills into must be empty. If they are not, FILTER returns a #SPILL! error.



Several Conditions: AND

To keep only the rows that meet two conditions, put each condition in parentheses and multiply them with *.

List the Bug Pokemon with a Total above 300. Replace the formula in G2 with this one:

GHIJK
1ID#NameType 1Type 2Total
212ButterfreeBugFlying395
315BeedrillBugPoison395
=FILTER(A2:E21, (C2:C21="Bug")*(E2:E21>300))

There are six Bug Pokemon, but only Butterfree and Beedrill have a Total above 300.

Why multiply? Each condition gives TRUE or FALSE for every row. Excel counts TRUE as 1 and FALSE as 0. 1*1 is 1, and anything times 0 is 0. So only the rows where both conditions are TRUE are kept.

Note: The AND and OR functions do not work for this. They return one TRUE or FALSE for the whole range, not one for each row.


Several Conditions: OR

To keep the rows that meet at least one of the conditions, add the conditions with +.

List the Pokemon with Water or Fire as Type 1:

GHIJK
1ID#NameType 1Type 2Total
24CharmanderFire0309
35CharmeleonFire0405
46CharizardFireFlying534
57SquirtleWater0314
68WartortleWater0405
79BlastoiseWater0530
=FILTER(A2:E21, (C2:C21="Water")+(C2:C21="Fire"))

A row is kept when the sum is 1 or more. That means at least one of the conditions is TRUE.

The rows come in the same order as in the table. The Fire Pokemon come first, because they are higher up in the table. To change the order, use the SORT function.


If Nothing Is Found

There are no Psychic Pokemon in the table. If nothing matches, FILTER returns #CALC!:

GHIJK
1ID#NameType 1Type 2Total
2#CALC!
=FILTER(A2:E21, C2:C21="Psychic")

Use the if_empty part to show your own message instead:

GHIJK
1ID#NameType 1Type 2Total
2No Pokemon found
=FILTER(A2:E21, C2:C21="Psychic", "No Pokemon found")

Note: Text in a formula must be inside double quotes: " "


Filter Command vs FILTER Function

Filter commandFILTER function
How you use itClick the filter buttons in the header rowType a formula in a cell
The resultRows that do not match are hidden in the tableA new list of the matching rows, where you type the formula
When the data changesYou must apply the filter againThe list updates by itself
Excel versionsAll versionsMicrosoft 365, Excel 2021, Excel 2024 and Excel for the web

Use the Filter command to look through a table quickly. Use the FILTER function when you want the matching rows in their own list, for example on a report or a second sheet.

See also: UNIQUE lists the different values in a range, COUNTIFS counts the rows that match several conditions, and XLOOKUP returns only the first match.


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.