Locked lesson.
About this lesson
Combining multiple conditions in a single FILTER() to restrict the results of a Dynamic Array
Exercise files
Download the ‘before’ and ‘after’ Excel workbooks from the video tutorial and try the lesson yourself.
Multi-Condition DA FILTERing.xlsx43.1 KB Multi-Condition DA FILTERing - Complete.xlsx
43.3 KB
Quick reference
FILTER-ing Dynamic Arrays with Multiple Conditions
Working with the FILTER function to reduce the results of a dynamic array based on multiple conditions.
When to use
When you need to filter certain items out of your dynamic array results based on multiple conditions.
Instructions
Availability
- Dynamic arrays were released to Microsoft 365 AFTER Excel 2019 was released
- This means that you must have a version of Excel newer than Excel 2019 to use them
Using FILTER()
- Can be used with table components or ranges
- Syntax: =FILTER( array, include, [if_empty] )
- The array parameter can have any number of rows/columns
- The “include” formula must be a single column (row) compared to a value
- The “include” formula must have the same number of rows (columns) as the original array
Filtering on a Single Condition
- Returning the rows from the Sales table where the Category = Beer:
- =FILTER( Sales, Sales[Category] = "Beer" )
- Returning a block of data where the value in column E = 10
- =FILTER( A10:C30, C10:C30 = 10 )
Operators for AND and OR in Dynamic Array Filtering
- * Used to denote “And”
- + Used to denote “Or”
- Remember:
- The “include” parameter of the filter must be wrapped in parenthesis before using a * or + character
- If you include multiple OR tests using +, as well as an AND test using *, you must also wrap all the OR tests in a surrounding set of parenthesis as well
Filtering on Multiple Conditions
- Returning the rows from the Sales table where the Category = Beer OR Wine:
- =FILTER( Sales, ( Sales[Category] = "Beer" ) + ( Sales[Category] = "Wine" ) )
- I.e. wrap each “include” test in parenthesis before joining them with +
- Returning the rows from the Sales table where the Category = Beer AND Year = 2020:
- =FILTER( Sales, ( Sales[Category] = "Beer" ) * ( Sales[Year] = 2020 ) )
- I.e. wrap each “include” test in parenthesis before joining them with +
- Returning the rows from the Sales table where the Category = Beer OR Wine, AND Year = 2020:
- =FILTER( Sales, ( ( Sales[Category] = "Beer" ) + ( Sales[Category] = "Wine" ) ) * ( Sales[Year] = 2020 ) )
- I.e. Failure to wrap the OR structure for the Beer and Wine tests in an additional set of parenthesis would result in “Category = Beer” OR “Category = Wine and Year = 2020”
Lesson notes are only available for subscribers.