Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel for iPad Excel for iPhone Excel for Android tablets Excel for Android phones More…Less
The FILTER function allows you to filter a range of data based on criteria you define.
In the following example we used the formula =FILTER(A5:D20,C5:C20=H2,»») to return all records for Apple, as selected in cell H2, and if there are no apples, return an empty string («»).
The FILTER function filters an array based on a Boolean (True/False) array.
=FILTER(array,include,[if_empty])
Argument |
Description |
array Required |
The array, or range to filter |
include Required |
A Boolean array whose height or width is the same as the array |
[if_empty] Optional |
The value to return if all values in the included array are empty (filter returns nothing) |
Notes:
-
An array can be thought of as a row of values, a column of values, or a combination of rows and columns of values. In the example above, the source array for our FILTER formula is range A5:D20.
-
The FILTER function will return an array, which will spill if it’s the final result of a formula. This means that Excel will dynamically create the appropriate sized array range when you press ENTER. If your supporting data is in an Excel table, then the array will automatically resize as you add or remove data from your array range if you’re using structured references. For more details, see this article on spilled array behavior.
-
If your dataset has the potential of returning an empty value, then use the 3rd argument ([if_empty]). Otherwise, a #CALC! error will result, as Excel does not currently support empty arrays.
-
If any value of the include argument is an error (#N/A, #VALUE, etc.) or cannot be converted to a Boolean, the FILTER function will return an error.
-
Excel has limited support for dynamic arrays between workbooks, and this scenario is only supported when both workbooks are open. If you close the source workbook, any linked dynamic array formulas will return a #REF! error when they are refreshed.
Examples
FILTER used to return multiple criteria
In this case, we’re using the multiplication operator (*) to return all values in our array range (A5:D20) that have Apples AND are in the East region: =FILTER(A5:D20,(C5:C20=H1)*(A5:A20=H2),»»).
FILTER used to return multiple criteria and sort
In this case, we’re using the previous FILTER function with the SORT function to return all values in our array range (A5:D20) that have Apples AND are in the East region, and then sort Units in descending order: =SORT(FILTER(A5:D20,(C5:C20=H1)*(A5:A20=H2),»»),4,-1)
In this case, we’re using the FILTER function with the addition operator (+) to return all values in our array range (A5:D20) that have Apples OR are in the East region, and then sort Units in descending order: =SORT(FILTER(A5:D20,(C5:C20=H1)+(A5:A20=H2),»»),4,-1).
Notice that none of the functions require absolute references, since they only exist in one cell, and spill their results to neighboring cells.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See Also
RANDARRAY function
SEQUENCE function
SORT function
SORTBY function
UNIQUE function
#SPILL! errors in Excel
Dynamic arrays and spilled array behavior
Implicit intersection operator: @
Need more help?
This post will guide you how to extracts matched values using FILTER function in Microsoft Excel 365. And also will introduce that how to use FILTER function with same examples in Excel 365.
Table of Contents
- Excel Filter Function
- Entering FILTER Formula in Excel
- Excel filtering by a single criteria
- Example 1: How to use a number as a filter
- Example 2: How to filter in Excel by a cell value
- Example 3: Using Excel’s text filter
- Example 4: Using NOT EQUAL TO as a FILTER condition in Excel
- Example 5: How to use the date filter in Excel
- Example 6: Filtering by date in Excel
- Example 7: Filtering based on two Conditions
- Example 8: Filtering Based on Two Conditions using OR Logic
- Example 9: Filter Data in Excel from Another Sheet
- Example 10: Providing Maximum Number of Rows of Filtered Data
- Conclusion
- Related Functions
The FILTER function “filters” a set of data according to the conditions specified. The outcome is an array of values that match those in the original range. Simply said, the FILTER function extracts matched records from a collection of data using one or more logical checks. The include argument specifies logical tests, which might encompass a wide variety of formula conditions. For instance, FILTER may match data from a given year or month, data containing specific content, or numbers above a specified threshold.
=FILTER(array,include,[if empty])
Three parameters are required for the FILTER function: array
, include
, and if empty
.
Where:
- Array – This is required argument. The range or array to filter is specified by array.
- Include – This is required argument. Include one or more logical tests in the include These tests should return TRUE or FALSE depending on the array values evaluated.
- If_empty – This is option argument. The last input, if empty, specifies the value to return if FILTER does not discover any matching values. Typically, this is a message along the lines of “No records found,” although other values may also be returned. To show nothing, provide an empty string (“”).
Entering FILTER Formula in Excel
FILTER provides dynamic results. When the values in the source data change or the size of the source data array changes, the FILTER results are updated automatically. The results of FILTER will “leak” into numerous cells on the worksheet.
To filter data in Excel using the FILTER function, follow these steps:
Step1: To begin your filter formula, enter =FILTER(
.
Step2: Enter the address for the range of cells containing the data you want to filter, for example, A2:C10.
Step3: Type a comma, followed by the filter's condition
, such as B2:B20>3
(To specify a condition, type the address of the “criteria column,” such as C1:C, followed by an operator symbol such as greater than (>), and finally the criterion, such as the number 3.
Step4: Complete the parenthesis with a closing parenthesis and then hit enter on the keyboard. Your full formula will appear as follows: =FILTER(A2:C10, B2:B20>3)
I’ll begin with the fundamentals of utilizing the FILTER function, and then demonstrate some more advanced uses of the FILTER function. This article discusses the FILTER function as a formula entered into spreadsheet cells, not the filter command accessible from the toolbar and pop-up menus.
While using the FILTER function in Excel is almost identical to using it in Google Sheets, there are some subtle variations.
Excel filtering by a single criteria
To begin, let’s review how to use Excel’s FILTER function in its simplest version, with a single condition/criteria.
I’ll demonstrate how to filter data using a number, a cell value, a text string, or a date… and I’ll also demonstrate how to utilize a variety of “operators
” in the filter condition (Less than, Equal to, etc…).
Example 1: How to use a number as a filter
In this first demonstration of how to use the filter tool in Excel, we have a list of students and their grades and wish to create a filtered list of only students with flawless grades.
The assignment: Display a list of students and their grades, but only those who have earned an A.
The reasoning: Filter the range A2:B10 for values larger than 0.7 in the column B2:B10 (70 percent ). Then you can use the following FILTER formula,type:
=FILTER(A2:B10, B2:B10 >0.7)
Example 2: How to filter in Excel by a cell value
In this excel filter function example, we want to do the same thing as stated before, but rather than inputting the condition straight into the formula, we’re going to use a cell reference.
When you filter in Excel by a cell value, your sheet is configured in such a way that you may alter the value in the cell at any moment, which updates the value to which the filter criterion is tied.
In this example, rather than explicitly entering the value “0.8” into the formula, the filter criterion is set to cell G1, which contains the “0.8
” value.
The assignment: Display a list of students and their grades, but only those with a score of less than 80%
.
The reasoning: Filter the range A2:B10 to the extent that B2:B10 is smaller than the value supplied in column G1 (0.8).
You can use the following FILTER formula, type:
=FILTER(A2:B10, B2:B10 <G1)
Example 3: Using Excel’s text filter
In this example, we’ll utilize a text string as the filter formula’s criterion. This is fairly similar to using a number, except that the text to filter must be enclosed in quote marks.
We are filtering a list of customers and their payment status in this instance, and we want to present just customers with a payment status of “Payed
“.
The objective is to provide a list of clients that have paid on their payments.
The reasoning: Filter the range A2:B6 by substituting the string “ Payed
” for B2:B6.
The following formula: In this example, the formula below is typed in the cell (E1).
=FILTER(A3:B12, B2:B6=" Payed ")
Example 4: Using NOT EQUAL TO as a FILTER condition in Excel
Now that you have a working knowledge of how to use the filter function in Excel, here is another example of filtering by a string of text, but this time we will use the “not equal” operator (<>) to demonstrate how to filter a range and return data that is NOT equal to the criteria you set.
Additionally, we will utilize a bigger data set in this example to show a more comprehensive usage of the FILTER function in the real world.
You may be surprised at how often a circumstance arises in which you need to filter data that is “not equal to
” a certain number or piece of text.
In this example, we’ll use a report/spreadsheet to display data from sales calls that occur at your organization, and we’ll filter the data to exclude a certain sales person (Scott) from the result.
The assignment: Display sales call statistics for all sales representatives except ” Scott “.
The reasoning: Filter the range A2:C10
for values A2:A10
that DO NOT match the string “Scott “.
The following formula: In this example, the formula below is typed in the cell (E1).
=FILTER(A2:C10, A2:A10 <>"Scott")
Take note that the filtered data on the right side of the figure above does not include any of Scott
‘s rows/calls.
Example 5: How to use the date filter in Excel
Filtering in Excel by a date may be accomplished in a few different methods, which I will demonstrate below. If you attempt to put a date into the FILTER function in the same way that you would typically type into a cell, the formula will fail to operate properly.
Therefore, you may either enter the date you want to filter into a cell and then reference that cell in your formula… Alternatively, you may use the DATE function.
When filtering by date, the same operators (>, =, etc…) are available as they are in other FILTER function applications. Each individual day/date in Excel is merely a number that has been formatted differently. In Excel, for example, the date “01/30/2022
” is just the serial number “44591
” formatted as a date. Each time you add a day to the calendar, this number increases by one… For example, “44591” “44592” “44593”
Thus, if one date is farther in the future, it might be regarded “greater than
” another. In contrast, if one date is farther in the past, it might be considered to be “less than
” another.
In this example, we’ll use a cell reference to filter on a date. This is identical to the example discussed in Example 2, except that we are dealing with dates instead of percentages.
Consider the following scenario: we want to filter a list of students, their exam results, and the dates on which the tests were administered… and we wish to display only tests conducted before to June (05/01/2022).
=FILTER(A2:C10, C2:C10 <G1)
Example 6: Filtering by date in Excel
In this example of date filtering in Excel, we’ll use the same data as in the previous one and attempt to obtain the same results… however, instead of referencing a cell, we’ll utilize the DATE function, which allows you to put the date straight into the FILTER function.
When using the DATE function to provide a date, you must first input the year, followed by the month and finally the day… each denoted with a comma (shown below).
The assignment: Display only exams given before to May
The reasoning: Filter the range A2:C10
so that C2:C10
is less than or equal to the date (05/01/2022).
The following formula: In this example, the formula below is typed in the cell (D3).
=FILTER(A2:C10,C2:C10<DATE(2022,5,1))
Example 7: Filtering based on two Conditions
When utilizing the Excel FILTER function, you may want to produce data that fits many criteria. I’ll demonstrate two methods for filtering by several criteria in Excel, depending on the scenario and the desired behavior of the calculation.
The conventional method of adding another condition to your filter function (as shown by the Excel formula syntax) allows you to provide a second condition, where both the first AND second conditions must be fulfilled in order for the filter output to be returned.
However, I will demonstrate how to make a little tweak to the function so that you may choose to return/display in the filter function’s output/destination a second condition where EITHER condition might be satisfied. (To utilize AND logic, separate the conditions with an asterisk, or use a plus symbol to separate the criteria.)
In this example, we’re going to filter a collection of data and show those rows that satisfy BOTH the first and second conditions.
To utilize a second condition in this manner (using AND logic), just insert it after the first condition in the formula, separated by an asterisk (*)
. Each condition must be included in a separate pair of parentheses.
When a filter formula is used with several conditions, the columns referenced in each condition must be distinct.
In this case, we’d want to filter a list of clients based on their payment status and region… and to display those customers who are both current members AND paid on their payment status.
The objective is to provide a list of customers who are paid on payments, but only those who are in East region.
The reasoning:Filter the range A2:C6 such that B2:B6 equals the text “Paid
,” AND C2:C6 equals the text “East
“.
The following formula: In this example, the formula below is typed in the blue cell (E1).
=FILTER(A2:C6,( B2:B6="Paid")*( C2:C6 ="East"))
Example 8: Filtering Based on Two Conditions using OR Logic
In this example, we’re going to filter a collection of data and show those rows that satisfy either the first OR the second criterion.
To utilize a second condition in this manner (using OR logic), just insert it after the first condition in the formula, separated by a plus sign
. Each condition must be included in a separate pair of parentheses (shown below).
When used in this manner, the FILTER formula allows you to choose criteria from the same or separate columns.
In this case, we’re filtering the same customer data as in the previous example, but this time we’re displaying a list of customers who either are in East
region OR have paid on a payment. This will generate a list of clients to whom a payment notification have paid… whether they are current members or east region who have paid on their last payment.
The objective is to provide a list of customers who are in East
region, as well as customers who have paid on payments regardless of whether they are in East region.
The following formula: In this example, the formula below is typed in the cell (E1).
=FILTER(A2:C6, (B2:B6="Paid ")+(C2:C6=" East ")
Example 9: Filter Data in Excel from Another Sheet
You may often encounter instances in Excel when you need to filter data from another sheet, where your raw unfiltered data is on one tab and your filter formula is on another sheet.
This may be accomplished by simply referring to a certain sheet’s name when providing the filter’s ranges. Thus, while you would typically give a range such as “A1:B4,” when referring another sheet when filtering, you indicate the sheet name by preceding the range with the sheet name and an exclamation mark, as in “SheetName!A1:B4
“.
However, if the sheet name contains a space, an apostrophe must be used before and after the sheet name, as in "Sheet Name!" A1:B4
.
The following is an example of how to filter data in Excel from a separate sheet, where the filter formula is located on a different sheet than the source range.
Consider the following scenario: On one sheet, you have a list of customers and their payment status, and you wish to present a filtered list of paid customer on another sheet.
The job is to filter the list of customers on the Sheet3 and to display a separate list of customer names with a pay status on another worksheet.
The reasoning: Filter the range using the Sheet3
‘ command! A2:C6, where ‘ Sheet3′ is the range! B2:B6 corresponds to the phrase “Paid“.
The following formula: In this example, the formula below is typed in the cell (A3).
=FILTER(Sheet3! A2:C6, Sheet3!B2:B6="Paid")
Example 10: Providing Maximum Number of Rows of Filtered Data
If your FILTER formula provides a large number of rows but your worksheet is restricted in space and you are unable to erase the data below, you may limit the amount of rows returned by the FILTER function.
Let us demonstrate how it works using a simple formula that filter data that grade is less than 0.7 from filter value in Cell F1:
=FILTER(A2:C10, B2:B10<F1)
The preceding formula produces all records that it discovers, in this instance five rows. However, imagine you only have room for two. To output just the first two rows discovered, follow these steps:
Step1: Incorporate the FILTER formula into the INDEX function’s array parameter
Step2: Use a vertical array constant such as 1;2 as the row num input to INDEX. It specifies the number of rows to return (2 in our case).
Step3: Use a horizontal array constant such as 1,2 for the column num parameter. It defines the columns that should be returned (the first 2 columns in this example).
Step4: To account for any mistakes caused by the absence of data meeting your criteria, you may wrap your calculation in the IFERROR function.
The entire excel filter formula is as follows:
=IFERROR(INDEX(FILTER(A2:C10, B2:B10<F1), {1;2},{1,2}), "No Found")
Conclusion
This section discusses the FILTER function and its many uses. In general, when it comes to time management, we need this feature for a variety of reasons. I demonstrated various techniques with accompanying examples, however there might be countless further iterations based on a variety of circumstances. If you know of another way to use this function, please share it with us.
- Excel IFERROR function
The Excel IFERROR function returns an alternate value you specify if a formula results in an error, or returns the result of the formula.The syntax of the IFERROR function is as below:= IFERROR (value, value_if_error)…. - Excel INDEX function
The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])…
Facing problem just because your filter not working in Excel? No need to suffer from this problem anymore….!
As today I have chosen this specific topic of “Excel filter not working” to answer. All in all this post will help you to explore the reasons behind why Filter Function Not Working In Excel and ways to fix Excel filter not working issue.
Why Is Your Filter Not Working In Excel And Ways To Fix It?
Reason 1# Excel Filter Not Working With Blank Rows
One very common problem with the Excel filter function is that it won’t work with the blank rows. Excel Filter doesn’t count the cells with the first blank spaces.
To fix this, you need to choose the range right before using the filter function. For a clearer idea of how to perform this task, check out the following example.
- Before using the Excel filter function on the column C. either you can choose the column “C” completely or just select the data which you want to filter out.
- From the “data” tab select the “Filter” option. Now all the items become visible in the filter checkbox list or filtered list.
- Similarly, you have to choose the cell ranges or multiple columns before the application of the filter function.
To fix damaged Excel workbook, we recommend this tool:
This software will prevent Excel workbook data such as BI data, financial reports & other analytical information from corruption and data loss. With this software you can rebuild corrupt Excel files and restore every single visual representation & dataset to its original, intact state in 3 easy steps:
- Download Excel File Repair Tool rated Excellent by Softpedia, Softonic & CNET.
- Select the corrupt Excel file (XLS, XLSX) & click Repair to initiate the repair process.
- Preview the repaired files and click Save File to save the files at desired location.
Reason 2# Make Proper Selection Of The Data
If your spreadsheet contains empty rows or columns. Or if you only want to filter out only the specific range then choose the section which you want to filter prior to turning on the Filter.
If you don’t choose the area then Excel applies the filter on the complete one. This can also result in selection up to the first empty column or rows excluding the data present after the blanks.
So it will be better if you manually select the data in which you want to apply the Excel filter function.
- In order to remove the blank rows from the selected filter area. First of all turn on the filter and then click on the drop-down arrow present in any columns to show the filter list.
- Now remove the check sign across the ‘(Select All)’ after then shift right on the bottom of the filter list. Choose the ‘(Blanks)’ option and tap to the OK.
- After this only, the blank rows will clearly appear on your screen.
- For easy identification, the row number of each blank row appears in blue color.
- For deleting up these blank rows. You need to select these rows first and then make a right-click over the anyone of the blue color row number. Choose the Delete option from the listed option to delete the select blank rows.
- By turning off the filter you can see the rows that are now been removed.
Reason 3# Check The Column Headings
- Check the data which has only one row of column headings.
- In order to get multiple lines for the heading, into the cell you just need to type the first line. After that press “ALT + ENTER” option for typing in the new line of the cell.
- In such cases, the Wrap Text function also works great in formatting the cells correctly.
Reason 4# Check For Merged Cells
Another reason for your Excel filter not working is because of the merged cells.
So unmerge if you have any merged cells in the spreadsheet.
If the column headings are being merged, then the Excel filter becomes unable to choose the items present from the merged columns.
The same thing happens with the merged rows. Excel filter won’t count the merged rows data.
For unmerging the cells:
-
Go to the Home tab and to the Alignment group.
-
Now hit the down arrow present across Merge & Center and choose the Unmerge Cells option.
Reason 5# Check For Errors
Check carefully that your data doesn’t include any errors.
Suppose, if you are filtering the ‘Top 10’, ‘Above Average’ or ‘Below Average’ values within your list then using the Number Filters gets compulsory. Otherwise, the error may hinder your Excel application to apply the filter.
- For removing up the errors use the filters to fetch them. Usually, they get listed at the list’s bottom so scroll down.
- Choose the error and tap to the OK option. After locating up the error, fix or delete it and then only clear up the filter.
Reason 6# Check For The Hidden Rows
On the Excel filter, list hidden rows won’t appear as the filter option.
- For unhiding the rows firstly you need to choose the area having the hidden rows. This means you have to choose the rows to present below or above of the hidden data.
- After that either you can make a right-click over the rows header area. Or you can choose the Unhide option. OR just go to the Home tab > cells group> Format> Hide & Unhide> Unhide Rows option.
Reason 7# Check For The Other Filters
Check that your filter is not been left on any other column.
The best option for clearing up all the Excel filters is by tapping to the Clear button present on the ribbon (which is on the right section of the filter button).
This will leave the filter turned on, but it will clear all the filter settings. So now you can make a fresh start with your complete data.
Reason 8# The Filter Button Is Greyed Out
If your Filter function button is appearing gray in color then it means that the filter not working in Excel. The reason behind this can be that your grouped worksheets.
So check out whether your worksheets are grouped or not.
- You can easily identify it by watching out the title bar where generally the filename appears at the screen top.
- If the ‘Your file name’ – Group is appearing then it means that your worksheet is grouped.
- In this case, ungrouping the worksheet can fix filter function not working in Excel issue.
- So come down to your worksheet and make a right-click on the sheet tab. After that choose the Ungroup Sheets option.
- You will see, after making these changes again the filter option starts appearing.
Reason 9# The ‘Equals’ Filter Isn’t Working
While using the Equals filter, Number Filter, or Date Filter, if your Excel is not showing the right data then check whether the format of your data is the same or not.
Suppose, if you are having 2 cells and in each cell, you have entered 1000 as data. One cell is formatted in “currency” format and another one is formatted in “number” format. So when you make use of the “Number Filters, Equals” option, then Excel will only fetch the matches in which you have typed the number format also.
Only typing the text 1000 will search the match for the cells only in the number format. Whereas typing the text $1,000.00 will look for the cells which are formatted as ‘Currency’.
The same rule is also applicable in the case of dates. 16-Jan-19 and 16/01/2019 both are different. Thus make sure that the complete data column is formatted in the same format to avoid filter function not working in Excel issue.
Wrap Up:
The very first thing that Excel filters always check is whether your data matches well with its basic layout standards or not. If you are following all the Excel filters rules then you won’t get Excel filter not working issue.
So, take a close check whether you are following all the above mentioned Excel Filter rules correctly or not.
If none of the above fixes works to resolve your Excel Filter Not Working issue then ask about your queries on our Facebook and Twitter page.
Priyanka is an entrepreneur & content marketing expert. She writes tech blogs and has expertise in MS Office, Excel, and other tech subjects. Her distinctive art of presenting tech information in the easy-to-understand language is very impressive. When not writing, she loves unplanned travels.
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 values in A1:A10 that are greater than 100:
=FILTER(A1:A10,A1:A10>100)
To extract rows in A1:C5 where the value in A1:A5 is greater than 100:
=FILTER(A1:C5,A1:A5>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 same.
Note: FILTER will return a #CALC! error if no matching data is found
Filter for Red group
In the example shown above, 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")
No matching data
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:
=FILTER(range,logic) // #CALC! error
Often, is_empty is configured to provide a text message to the user:
=FILTER(range,logic,"No results") // display message
To display nothing when no matching data is found, supply an empty string («») for if_empty:
=FILTER(range,logic,"") // display nothing
Values that contain text
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:
=FILTER(rng1,MONTH(rng2)=7,"No data")
This formula relies on the MONTH function to compare the month of dates in rng2 to 7. See full explanation here.
Multiple criteria
At first glance, it’s not obvious how to apply multiple criteria with the FILTER function. Unlike older functions like COUNTIFS and SUMIFS, which provide multiple arguments for entering multiple conditions, the FILTER function only provides a single argument, include, to target data. The trick is to create logical expressions that use Boolean algebra to target the data of interest and supply these expressions as the include argument. For example, to extract only data where one value is «A» and another is greater than 80, you can use a formula like this:
=FILTER(range,(range="A")*(range>80),"No data")
The math operation of addition (*) joins the two conditions with AND logic: both conditions must be TRUE in order for FILTER to retrieve the data. See a detailed explanation here.
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
- FILTER can work with both vertical and horizontal arrays.
- The include argument must have dimensions compatible with the array argument, otherwise FILTER will return #VALUE!
- If the include array includes any errors, FILTER will return an error.
To make it easy to filter for several different items, you create a list of those items on a worksheet. Then, filter your data based on that list, so you don’t have to check all the items manually each time.
Video: Filter Exact Match List Items
Watch this video to see how to set up an Advanced Filter, and filter for exact matches in the item list.
To get the Microsoft Excel file, so you follow along with the video, go to the Excel Advanced Filter Criteria page on my Contextures site. In the download section, look for the Match Items in List sample workbook
NOTE: There are written steps below the video, for another Filter to Match List Items example.
Your browser can’t show this frame. Here is a link to the page
Two Options for Filtering
Here’s the sample data, and the list of items that we want to filter. The table in column F is named tblFind, and cells F2:F3 are named FindList.
We’ll look at two options for filtering the list:
- Filter rows that have an exact Product match for items in the list
- Filter rows that contain an item in the list, anywhere in the Product field
Advanced Filter
Both options will use an Advanced Filter, so a Criteria range is added to the worksheet.
We’ll be using a formula in the criteria cell, so type a heading that is different from any column header in the data table, or leave the criteria heading blank.
Exact Match For Items in List
For the first filter, we want to find rows with a product that is an exact match for one of the list items.
- In cell C2, enter the following formula. It refers to the named range in the list of items, and the first Product cell in the data table.
=COUNTIF(FindList,C5)
The formula uses the COUNTIF function to check each record, and test for the list items. Rows with an exact match will be returned in the filter.
Run the Advanced Filter
To run the Advanced Filter, and show the results in place, follow these steps:
- Select a cell in the data table
- On the Data tab of the Ribbon, in the Sort & Filter group, click Advanced, to open the Advanced Filter dialog box
- For Action, select Filter the list, in-place
- For List range, select the data table
- For Criteria range, select C1:C2 – the criteria heading and formula cells
- Click OK, to see the results
The 4 rows that have a product that is exactly “Milk” or “Cookies” (case does not matter), are visible, and all other rows are hidden.
Partial Match: Contain Item in List
For the second filter, we want to find rows with a product that contains one of the list items, anywhere in the Product name cell.
- In cell C2, enter the following formula. It refers to the named range in the list of items, and the first Product cell in the data table.
=SUMPRODUCT(COUNTIF(C5,”*”& FindList &”*”))>0
The COUNTIF function checks each Product cell, and tests for the list items. The * wildcards are used before and after the list item, so the text can be found anywhere in the Product cell.
The SUMPRODUCT function sums the number, and if it’s greater than zero, the result is TRUE.
- Tip: See more SUMPRODUCT examples on my Contextures site.
Run the Filter
Next, run the Advanced Filter with the same settings as in the first example, and the 6 rows that contain “Milk” or “Cookies” (upper or lower case does not matter) in the product cell are visible.
Download the Sample File
To get the Excel file for the Exact Match video, go to the Excel Advanced Filter Criteria page on my Contextures site. In the download section, look for the Match Items in List sample workbook
The zipped file is in Excel xlsx format, and does not contain any macros
Related Links
Advanced Filter Basics
Advanced Filter Criteria
Advanced Filter Criteria Slicers
Advanced Filter Macros
Filter to Different Sheet
Filter Unique Items
____________