If the only way you know of creating a filter in Google Sheets is the standard tool, I have a surprise for you. :) Come explore the FILTER function with me. There are plenty of ready-made formulas you can borrow, along with a new powerful tool that complements the filtering toolset immensely.
Some time ago we explained how to filter in Google Sheets using the standard tool. We mentioned how to filter by value and by condition. However, spreadsheets always have more in them than we know. And this time I'm going to explore the Google Sheets FILTER function with you.
You won't find it in Excel, so it is definitely worth checking out.
Syntax of the Google Sheets FILTER function
FILTER in Google Sheets scans your data and returns the required information that meets your criteria.
Unlike the standard Google Sheets filter, the function doesn't do anything with your original data. It copies the found rows and puts them wherever you build the formula.
The syntax is pretty easy since each argument speaks for itself:
- range is the data you want to filter. Required.
- condition1 is a column or row along with the TRUE/FALSE criteria it should fall under. Required.
- condition2,..., etc., stand for other columns/rows and/or other criteria. Optional.
Note. Each condition should be of the same size as the range.
Note. If you use multiple conditions, they should all be either for columns or rows. Google Sheets FILTER function doesn't allow mixed conditions.
Now, with these notes in mind, let's see how the arguments take shape of different formulas.
How to use FILTER function in Google Sheets
I'm going to show you all the examples while filtering a small table where I track some orders:
The table contains 20 rows with various types of data which is perfect to learn the function.
How to filter in Google Sheets by text
Example 1. Text is exactly
First, I will ask the function to show only those orders that are running late. I enter the range to filter — A1:E20 — and then set the condition — column E should equal Late:
Example 2. Text is exactly not
I can ask the function to get me all orders but those that are late. For that, I will need a special comparison operator (<>) that means not equal to:
Example 3. Text contains
Now I'd like to show you how to build the Google Sheets FILTER function based on the partial match. Or in other words — if text contains.
Did you notice that order IDs in column A contain country abbreviations at their end? Let's create a formula to retrieve only orders that were shipped from Canada (CA).
Normally, you'd use wildcard characters for this task. But when it comes to the FILTER formula, it is FIND and SEARCH functions that operate this way.
Tip. If you'd rather avoid nesting other functions when filtering by simple word occurrences, feel free to try out the add-on described at the end.
Note. If the text case is important, use FIND, otherwise, pick SEARCH.
The SEARCH function will do just fine for my example since the text case is irrelevant:
- search_for is the text I want to find. It's really important to wrap it with double-quotes: "ca". Required.
- text_to_search is the range to scan for the needed text. Required. It's A1:A20 for me.
- starting_at indicates the starting position for the search — the number of the character to start looking from. It's completely optional but I need to use it. You see, all order IDs consist of letters and numbers, meaning a pair of CA may occur somewhere in between. The identical pattern of all IDs allows me to look for CA starting from the 8th character.
After collecting all these parts together, I get the desired result:
How to filter by date and time in Google Sheets
Filtering by date and time also requires using additional functions. Depending on your criteria, you may need to embed DAY, MONTH, YEAR, or even DATE and TIME in the main Google Sheets FILTER function.
Tip. If you're not familiar with these or always mess things up with dates — no worries. The tool described at the end doesn't require any functions at all.
Example 1. Date is
To get ahold of those orders that are due on 9 January 2020, I'll invite the DATE function:
Note. This only works if your cells don't contain time units along with the date (you spreadsheet may add them by default). To make sure, just select a cell and check what appears in the formula bar:
If the time is there and removing it is not an option, you should use either QUERY or a more complex condition in your Google Sheets FILTER function, like this:
Tip. I talk about multiple conditions in more detail below.
Example 2. Date contains
If you're interested in a particular month or a year only, you can get by with MONTH and YEAR functions. Put the range with dates right into it (C1:C20) and specify the number of the month (or year) it should be equal to (=1):
Example 3. Date is before/after
To get the data that falls before or after the specified date, you will need the DATE function and such comparison operators as greater than (>), greater than or equal to (>=), less than (<), less than or equal to (<=).
Here are the orders that were received on and after 1 January 2020:
Of course, you can easily substitute DATE with MONTH or YEAR here. The result won't differ from the one above:
Example 4. Time
When filtering on Google Sheets by time, the drill is exactly the same as with dates. You use the additional TIME function.
For instance, to get only days with a timestamp after 2:00 PM, the formula will be:
However, when it comes to using the HOUR function (as with MONTH for dates), the game changes a bit. Time is tricky enough in spreadsheets, so a few adjustments are necessary.
To return all rows with timestamps between 2:00 PM and 12:00 PM, do this:
- Enclose the range with timestamps (A1:A10) in a separate HOUR function. This will indicate where to look.
- Then add another HOUR function to set the time itself.
Tip. See that the result doesn't include 12:41 PM? That's because the spreadsheet treats it as 00:41 which is less than 2:00.
If you find a more elegant solution, please share it in the comments section below.
How to filter in Google Sheets using cell references
Each time you create a Google Sheets filter formula, you need to enter the condition as is: whether a word or its part, the date, etc. Unless you're familiar with cell references.
They make lots of things about formulas easier. Because instead of typing everything out, you can simply refer to cells with conditions.
Remember how I looked for all orders that are late? I can quickly refer to E4 with the text Late to do the same:
The result won't differ at all:
You can repeat this with all the aforementioned formulas. For example, avoid adding more functions like DATE and just refer to the cell with a date of interest:
Tip. Cell references also let you filter from another sheet. You just have to bring the sheet name:
Google Sheets FILTER formulas with multiple criteria
While I mainly used one condition in all Google Sheets filter formulas before, it is more likely that you'll need to filter a table by a few conditions at a time.
Example 1. IS BETWEEN logic
To find all rows falling between two numbers/dates/times, the optional arguments of the function will come in handy — condition2, condition3, etc. You just duplicate the same range each time but with a new condition.
Look, I'm going to return only those orders that cost me more than $250 but less than $350:
Example 2. OR logic in the Google Sheets FILTER function
Sadly, to get all rows that contain different records in a column of interest, the previous way won't do. So how can I check all orders that are both on their way and late?
If I do try the previous method and enter each order status to a separate condition, I'll get the #N/A error:
Thus, to correctly set the OR logic in the FILTER function, I should sum these two criteria within one condition:
=FILTER(A1:E20,(E1:E20="Late")+(E1:E20="On the way"))
Add filter to Google Sheets to multiple columns
What's even more likely than applying a few conditions to one column is creating a filter in Google Sheets for multiple columns.
The arguments are all the same. But each new part of the formula requires a new range with its own criteria.
Let's try and make the FILTER function in Google Sheets return orders that fall under all the following rules:
- They should be $200-400 worth:
- Are due in January 2020:
- And are still on their way:
E1:E20="on the way"
Put all these parts together and your Google Sheets filter formula for multiple columns is ready:
=FILTER(A1:E20,B1:B20>=200,B1:B20<=400,MONTH(C1:C20)=1,E1:E20="on the way")
Formula-free way for advanced Google Sheets filter
FILTER function is great and all, but sometimes it can be too much. Keeping track of all arguments, delimiters, nested functions and whatnot can be extremely confusing and time-consuming.
Luckily, we have a better solution that transcends both Google Sheets FILTER function and their standard tool — Multiple VLOOKUP Matches.
Don't get puzzled by its name. It resembles Google Sheets VLOOKUP function because it searches for matches. Just as the FILTER function does. Just as I did above.
Here are 5 main advantages of the tool over the Google Sheets FILTER function:
- You won't have to think about operators for different conditions — just pick the one from the list:
- Enter dates and time as you always do in spreadsheets — no more special functions:
- Create and delete multiple conditions for multiple columns real quick:
- Preview the result and adjust conditions (if needed) before pasting everything to your sheet:
- Get the result as values or as a ready-made formula.