Sub topic 10
Filtering on Text, Blanks, and Dates
Assume you can enter formulas, use cell references, and compare values with operators such as =, <>, >, and >=. The examples use a table in columns A:D with a header row in row 1.
FILTER tests each row against one or more conditions. A condition produces TRUE or FALSE for each row. Only rows with TRUE remain in the result.
| Order | Region | Order date | Sales |
|---|---|---|---|
| 1001 | West | 2026-01-05 | 1200 |
| 1002 | East | 2026-01-12 | 900 |
| 1003 | West | 2026-02-03 | 1800 |
| 1004 | South | 2026-02-10 | 700 |
Match text values
To return rows where the Region column equals West, enter this formula in an empty area:
=FILTER(A2:D, B2:B="West")The comparison B2:B="West" creates a condition for every row. The result includes orders 1001 and 1003.
Text comparisons usually need the exact spelling and punctuation in the cells. To find text contained inside a longer value, use REGEXMATCH. This example finds regions containing the word west, without case sensitivity:
=FILTER(A2:D, REGEXMATCH(B2:B, "(?i)west"))REGEXMATCH uses a regular expression, which is a pattern for finding text. The (?i) part makes the match case-insensitive.
Include or exclude blanks
To return rows where the Region cell is not blank, compare it with an empty string:
=FILTER(A2:D, B2:B<>"")To return only rows with a blank Region cell, reverse the comparison:
=FILTER(A2:D, B2:B="")This test treats a formula that returns "" as empty. It does not remove spaces that someone typed into a cell. If cells might contain spaces, use LEN(TRIM(B2:B))=0 to detect values that are empty after spaces are removed.
Filter by dates
Google Sheets stores a real date as a number formatted to look like a date. Use DATE to create an unambiguous date value inside a formula.
This formula returns orders from January 1 through January 31, 2026:
=FILTER(A2:D, C2:C>=DATE(2026,1,1), C2:C<DATE(2026,2,1))The two conditions form an inclusive start and exclusive end range. Using the first day of the next month avoids problems with times stored alongside dates.
If imported dates are actually text, comparisons may not work as expected. Convert them before filtering, or use DATEVALUE when the text format is recognized by your spreadsheet locale. Check a sample cell with =ISNUMBER(C2) to see whether Sheets stores it as a number.
Combine text, blank, and date conditions
Separate conditions in FILTER use AND logic. This formula returns nonblank regions in the West during January:
=FILTER(A2:D, B2:B="West", B2:B<>"", C2:C>=DATE(2026,1,1), C2:C<DATE(2026,2,1))The explicit blank test is redundant when B2:B="West" is present, but it can make a longer formula easier to understand. For OR logic, add conditions instead. For example, this returns rows from either West or East:
=FILTER(A2:D, (B2:B="West")+(B2:B="East"))Each addition acts like “this condition or that condition.”
Exercise
Write a formula that returns columns A:D for nonblank rows whose order date is in February 2026.
Show answer
=FILTER(A2:D, A2:A<>"", C2:C>=DATE(2026,2,1), C2:C<DATE(2026,3,1))