Google Sheets QUERY: Blank, Null and Empty-String Conditions

Filter blank and non-blank rows in Google Sheets QUERY with is null and is not null, including empty strings, whitespace and formula blanks.

Use is null to return blank rows in a Google Sheets QUERY, and is not null to exclude them:

=QUERY(A1:C, "select * where A is not null", 1)

That returns rows where column A has a value. Flip the test to keep only blank rows:

=QUERY(A1:C, "select * where B is null", 1)

The final argument is the number of header rows in the source range. Use 0 when there is no header and 1 for one header row. Wrong header counts often look like filter bugs—see QUERY error troubleshooting if the output headers or types look wrong.

Blank, empty string, whitespace and formulas

These cases can all look empty while behaving differently:

What is in the cellLooks blank?Typical is null behaviour
Truly empty (never typed, cleared)YesTreated as null
Formula that returns ""YesCan be imported as an empty or null-like value; do not rely on appearance alone
Spaces only (" ")YesNot null—spaces are text
Non-breaking space (CHAR(160))YesNot null
Number 0NoNot null

is null / is not null are the correct QUERY tests for “blank column.” Comparing to '' is less reliable for truly empty cells and does not clean whitespace.

A formula such as =IF(A2="","",A2) displays blank but is not a physically empty cell—ISBLANK returns FALSE. When Sheets prepares a column for QUERY, its inferred column type can affect how an empty formula result is represented. Test the actual range rather than assuming every blank-looking cell behaves identically. If QUERY keeps or drops rows unexpectedly, normalise the column first (next section).

Return blank or non-blank rows

=QUERY(A1:C, "select * where B is null", 1)
=QUERY(A1:C, "select * where B is not null", 1)

Combine with other criteria:

=QUERY(A1:D, "select A, B, D where B is not null and D > 0", 1)

Group alternatives with parentheses:

=QUERY(A1:D, "select * where (B is null or C is null) and D > 0", 1)

For multiple logical conditions more generally, see multiple criteria in QUERY.

Helper column for empty strings and whitespace

When imported data, formulas or paste operations leave zero-length strings or spaces, clean the column before querying:

=ARRAYFORMULA(IF(LEN(TRIM(A2:A))=0,,A2:A))

That turns empty strings and whitespace-only cells into truly empty cells, then leaves real values alone. Point QUERY at the helper column (or wrap the cleaned range in the formula).

For non-breaking spaces copied from web pages, replace CHAR(160) before trimming:

=ARRAYFORMULA(TRIM(SUBSTITUTE(A2:A,CHAR(160)," ")))

Spaces-only cells are text, so they fail is null. After trimming to a zero-length string, convert those results to real blanks with the IF(LEN(...)=0,,...) pattern above.

Headers and column letters

  • Letter references such as A, B refer to columns in the data range you passed to QUERY, not always absolute sheet columns.
  • When the data is built with {...} arrays, use Col1, Col2, … instead of letters—see noncontiguous ranges in QUERY.
  • Set the third argument to the true number of header rows. If headers are wrong, types and labels drift, which produces odd filters and errors documented in QUERY errors troubleshooting.

Use FILTER when the condition is simpler

FILTER is often clearer when you do not need the query language:

=FILTER(A2:C, A2:A<>"")

Exclude whitespace-only values:

=FILTER(A2:C, LEN(TRIM(A2:A))>0)

For blank checks outside QUERY, see how to ignore blank and empty cells and not-null tests in Google Sheets. An older short form focused only on excluding blanks is ignore blank cells in QUERY.

Quick reference

RequirementQUERY condition
Blank column Awhere A is null
Non-blank column Awhere A is not null
Either A or B blankwhere A is null or B is null
Both A and B populatedwhere A is not null and B is not null
Empty strings / spaces still appearingClean with TRIM / helper column, then is null

If QUERY returns parse errors, NO_COLUMN, mismatched array sizes or mixed-type surprises instead of a blank-filter issue, continue with Google Sheets QUERY errors troubleshooting.