Multi-Condition Filtering in the Same Column (Google Sheets)

Published on

Multi-condition filtering in the same column refers to applying multiple conditions to one column while filtering rows in a range. This is simple with numeric, time, or date fields using comparison operators, as the FILTER function naturally supports it.

For example, you can filter a range where dates in column A fall between two dates (a date range) or where scores in a column fall between a minimum and maximum score.

But what about filtering a range where the dates in column A fall on more than one specific date or category?

We will discuss this topic in multi-condition filtering in the same column.

Filter Rows Matching Values in a Column Within a Certain Range

We have the following data in A1:C, which represents the delivery dates of a few items:

DateItemQty
20/07/2024Copper Pipes5
20/07/2024UPVC Pipes4
23/07/2024Brass Fittings18
23/07/2024Drain Pipes6
01/08/2024Shower Heads40
01/08/2024Water Filters5

We can use the following FILTER formula to filter the rows in the range where the dates in A2:A fall between 20/07/2024 and 31/07/2024:

=FILTER(A2:C, A2:A>=DATE(2024, 7, 20), A2:A<=DATE(2024, 7, 31))
Filter rows to match values in a column against a specified range

This follows the syntax FILTER(range, condition1, [condition2, …]).

Where:

  • range: A2:C – the range to filter
  • condition1: A2:A>= DATE(2024, 7, 20) – returns TRUE for cells with dates on or after July 20, 2024
  • condition2: A2:A<= DATE(2024, 7, 31) – returns TRUE for cells with dates on or before July 31, 2024

The dates in the conditions are specified as per the DATE function syntax DATE(year, month, day) to avoid issues associated with MM/DD/YYYY or DD/MM/YYYY formats. You can follow the same.

The FILTER function returns rows from the range where the conditions are evaluated to TRUE.

This is how we apply multiple conditions in the same column using the FILTER function in Google Sheets.

Note: You can also use the formula below:

=FILTER(A2:C, ISBETWEEN(A2:A, DATE(2024, 7, 20), DATE(2024, 7, 31)))

In this case, the condition is ISBETWEEN(A2:A, DATE(2024, 7, 20), DATE(2024, 7, 31)), which evaluates to TRUE wherever the date falls between the two specified dates, both inclusive. The syntax of ISBETWEEN is:

ISBETWEEN(value_to_compare, lower_value, upper_value, [lower_value_is_inclusive], [upper_value_is_inclusive])

The last two optional arguments are TRUE by default.

Filter Rows Matching Specific Values in a Column

In the sample data above, how do we filter the items with delivery dates 20/07/2024 and 01/08/2024?

Please note that the following formula is incorrect:

=FILTER(A2:C, A2:A=DATE(2024, 7, 20), A2:A=DATE(2024, 8, 1))

This formula will not work as intended because it cannot simultaneously match both conditions in the same column.

To explain further, condition1, i.e., A2:A = DATE(2024, 7, 20), evaluates to TRUE in certain rows, while condition2, i.e., A2:A = DATE(2024, 8, 1), evaluates to FALSE in those rows, or vice versa.

So, how do we correctly apply multiple conditions in the same column?

Combine both conditions using addition: condition1 + condition2. This results in TRUE (1) or FALSE (0) for each condition. The formula will return rows where the combined condition evaluates to TRUE (1).

Correct Formula:

=FILTER(A2:C, (A2:A=DATE(2024, 7, 20)) + (A2:A=DATE(2024, 8, 1)))

You can use the same approach to filter a text type column as well:

=FILTER(A2:C, (B2:B="Copper Pipes") + (B2:B="Water Filters"))

This will apply multiple conditions to filter the same column, where the column is filtered for the criteria “Copper Pipes” and “Water Filters.”

Filter Rows Matching Specific Values in a Column

Multi-Condition Filtering in the Same Column Using Criteria from a Range

We usually specify criteria in a range and refer to that in the formula when dealing with multiple criteria.

For example, if you want to filter a range for items “Copper Pipes” and “Water Filters” in column B, you can enter these criteria into two cells—say, “Copper Pipes” in cell D2 and “Water Filters” in cell D3—and use the formula:

=FILTER(A2:C, (B2:B=D2) + (B2:B=D3))

This approach works, but it’s not ideal for a large number of criteria. Instead, you can match a criteria range (e.g., D2:D3) against column B using the XMATCH function, like this:

=FILTER(A2:C, XMATCH(B2:B, D2:D3))
Multi-Condition Filtering in the Same Column Using Criteria from a Range

In this formula, XMATCH follows the syntax:

XMATCH(search_key, lookup_range, [match_mode], [search_mode])
  • where search_key is the range to be matched (B2:B) and lookup_range is the range containing the criteria (D2:D3).

XMATCH returns the relative position of each item in search_key within lookup_range if a match is found, otherwise, it returns #N/A.

The FILTER function returns rows where the condition is a number, meaning that XMATCH found a match.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Lookup Previous Values Dynamically in Excel and Google Sheets

Sometimes, you may want to look up the previous values relative to the current...

Sort Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

3 COMMENTS

  1. =FILTER(Data!$A:$AN,Data!$P:$P ="",Data!$E:$E ="",Data!$U:$U ="",(Data!$G:$G "Deal Cancelled")+(Data!$G:$G ""&"")+(Data!$G:$G""&"Buyback"))

    Error Occurred anyone helps me to get resolved this formula.

    • Hi, Arvind Kumar,

      You may please try either of the below Filter or Query formulas.

      Filter;

      =FILTER(Data!$A:$AN,Data!$P:$P ="",Data!$E:$E ="",Data!$U:$U ="",(Data!$G:$G= "Deal Cancelled")+(Data!$G:$G="")+(Data!$G:$G="Buyback"))

      Query;

      =QUERY(Data!$A:$AN,"Select * where P is null and E is null and U is null and (G= 'Deal Cancelled' or G is null or G='Buyback')")

      If this is not working, please explain the problem instead of giving a non-working formula.

      Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.