Skip to content
AnIntent

How to Use FILTER in Google Sheets With Two Conditions (and #N/A)

Write a Google Sheets FILTER formula with two conditions, filter columns instead of rows, drop blanks, and see why no matches returns #N/A.

AnIntent Editorial · · 3 min read

Hands typing on a laptop displaying a data spreadsheet
Photo by Gorilla ROI Data Connector on Unsplash
In this article
  1. The FILTER syntax Google documents
  2. How to filter rows with two conditions
  3. How to skip rows where a column is blank
  4. How to filter columns instead of rows
  5. Why FILTER shows #N/A when nothing matches
  6. A related function: UNIQUE
Share this article

The FILTER function in Google Sheets pulls out only the rows (or columns) of a range that meet your conditions. This guide covers a formula with two conditions, skipping blank rows, filtering columns instead of rows, and what to do about the #N/A you get when nothing matches.

The FILTER syntax Google documents

Google's FILTER help page gives the syntax as:

FILTER(range, condition1, [condition2, ...])
  • range is the data you want filtered.
  • condition1 is a column or row of TRUE/FALSE values that lines up with the first column or row of range. It can also be an array formula that works out to TRUE/FALSE.
  • condition2, ... are optional extra conditions of the same kind.

Two rules from that page cause most broken formulas:

  • Every condition must be the same length as range. If your data runs A2:B26, your condition must also cover rows 2 to 26.
  • All conditions must be the same type. You can't mix a row condition with a column condition.

How to filter rows with two conditions

You add a second condition as another argument. There's no AND function wrapped around them. Google's own example:

=FILTER(A2:B26, A2:A26 > 5, D2:D26 < 10)
  1. Click an empty cell with plenty of empty space below and to the right of it. This is where the results will appear.
  2. Type =FILTER( and select the data you want returned, here A2:B26.
  3. Type a comma and the first test, A2:A26 > 5.
  4. Type a comma and the second test, D2:D26 < 10.
  5. Close the bracket and press Enter.

The condition columns don't have to be inside range. In Google's example the formula returns columns A and B but tests column D. They only need to cover the same rows.

Google describes each condition as showing whether each row passes through, and its two-condition example implies a row has to pass both.

How to skip rows where a column is blank

Google's help page includes this sample for dropping rows where column A is empty:

=FILTER(A2:B10, NOT(ISBLANK(A2:A10)))

You can use this as one of your two conditions. For example, to keep only rows that have something in column A and a value above 5 in column B:

=FILTER(A2:B10, NOT(ISBLANK(A2:A10)), B2:B10 > 5)

Both conditions cover rows 2 to 10, matching the range.

How to filter columns instead of rows

FILTER also works sideways. Instead of a column of TRUE/FALSE values, give it a row that is as wide as your range. For a range B1:F20, which is five columns wide, a condition such as B2:F2 > 5 keeps only the columns whose value in row 2 is above 5:

=FILTER(B1:F20, B2:F2 > 5)

Google's page also shows that a condition can be a hard-coded array of TRUE/FALSE values, as in FILTER(A2:C5, {TRUE; TRUE; FALSE; TRUE}), which keeps the first, second and fourth rows.

Filtering rows and columns at once

One FILTER can handle rows or columns, not both. Google's note says to use the output of one FILTER as the range of another. For example, drop blank rows first, then keep only columns with a header:

=FILTER(FILTER(A2:F20, NOT(ISBLANK(A2:A20))), NOT(ISBLANK(A1:F1)))

The inner formula filters rows. The outer one uses a row condition, A1:F1, that is six columns wide to match A:F.

Why FILTER shows #N/A when nothing matches

This is expected behaviour. Google's help page says that if no values satisfy the conditions, FILTER returns #N/A. So a #N/A often means your formula is fine and nothing in the data passes the test.

Before changing the formula, check:

  • Are the conditions too strict? Loosen one test, for instance > 5 to > 0, and see if rows appear.
  • Do the ranges line up? A condition that is a different length from range breaks the formula.
  • Did you mix rows and columns? All conditions must be the same type.

Showing a message instead of #N/A

The Sheets version doesn't have one.

=IFERROR(FILTER(A2:B26, A2:A26 > 5, D2:D26 < 10), "No matches")

When a formula misbehaves, remove the wrapper first to see the real error. The same idea applies to lookups; our XLOOKUP guide for Google Sheets covers its own #N/A handling.

The FILTER page's "See also" list points to UNIQUE, which you can use to drop repeated rows from the result. If you want to remove duplicates from the source data itself, see how to remove duplicates in Google Sheets.

Common questions

Why does my FILTER formula return #N/A?

Google's help page says FILTER returns #N/A when no values satisfy the conditions. Check whether your tests are too strict before assuming the formula is broken.

Does Google Sheets FILTER have an if_empty argument like Excel?

No. The Sheets syntax is FILTER(range, condition1, [condition2, ...]) with no argument for a no-match message. Wrapping it in IFERROR is a common workaround.

Can FILTER filter rows and columns at the same time?

Not in one formula. Google says to use the output of one FILTER as the range of another FILTER.

How do I filter out blank rows?

Use NOT(ISBLANK()) as a condition, as in Google's sample =FILTER(A2:B10, NOT(ISBLANK(A2:A10))).

a man sitting in front of a laptop computer
How-to

How to Compare Two Documents in Google Docs (Including a Word File)

Use Tools > Compare documents to compare two Google Docs, or a Doc and a Word file, and get the differences as suggested edits.

· 3 min

More in Cloud & Productivity Software