Fix guide

QUERY not working in Google Sheets™? 9 causes + fixes

The QUERY function is powerful, but tiny details break it: header rows, column references, text quotes, date syntax, mixed data types, apostrophes, and IMPORTRANGE permissions. This guide gives you the quickest checks before rewriting the whole formula.

A safe starting pattern

For a normal range with one header row, start simple:

=QUERY(A1:D,"select A, B, D where B = 'Paid'",1)

The third argument, 1, tells Google Sheets™ there is one header row. If your selected range starts at row 2 and has no header, use 0 instead.

Cause 1 - The header-row argument is wrong

If QUERY guesses headers incorrectly, it can drop your first data row or treat a header as data.

Risky: =QUERY(A:D,"select A, B") Safer: =QUERY(A1:D,"select A, B",1) No header: =QUERY(A2:D,"select A, B",0)

Fix: always set the third argument instead of letting Sheets guess.

Cause 2 - You are using the wrong column reference style

Normal ranges use letters like A, B, and C. Array literals and IMPORTRANGE outputs often need Col1, Col2, and Col3.

Normal range: =QUERY(A:D,"select A, D where B = 'Paid'",1) Array/IMPORTRANGE: =QUERY(IMPORTRANGE(url,"Sheet1!A:D"),"select Col1, Col4 where Col2 = 'Paid'",1)

Fix: if the data source is wrapped in another function, try Col1 style references.

Cause 3 - You used header names instead of query columns

QUERY does not usually let you write select Revenue just because the header says Revenue. Use the column letter or Col number.

Wrong: =QUERY(A:D,"select Customer, Revenue",1) Right: =QUERY(A:D,"select A, D",1)

Fix: map each visible header to its actual query column before changing the formula.

Cause 4 - Text criteria are not quoted correctly

Text inside the query string needs single quotes. The formula string itself uses double quotes, so text criteria go inside single quotes.

Wrong: =QUERY(A:D,"select A where B = Paid",1) Right: =QUERY(A:D,"select A where B = 'Paid'",1)

If the criterion lives in a cell, concatenate it carefully:

=QUERY(A:D,"select A where B = '"&F1&"'",1)

Cause 5 - Date criteria are not written in QUERY format

QUERY dates need the date keyword and yyyy-mm-dd format.

Wrong: =QUERY(A:D,"select A where A >= 1/1/2026",1) Right: =QUERY(A:D,"select A where A >= date '2026-01-01'",1)

If the date is in a cell, use TEXT:

=QUERY(A:D,"select A where A >= date '"&TEXT(F1,"yyyy-mm-dd")&"'",1)

Cause 6 - A text value contains an apostrophe

Names like O'Brien or product labels with apostrophes can break a query string because the apostrophe closes the text criterion.

Fix: sanitize the criterion before concatenating it:

=QUERY(A:D,"select A where B = '"&SUBSTITUTE(F1,"'","\'")&"'",1)

If that becomes hard to maintain, use a helper column to normalize the criterion or switch to FILTER for the specific case.

Cause 7 - A column mixes numbers and text

QUERY infers one dominant data type per column. If an amount column mixes real numbers with text values like "15000" or "$15,000", some rows can become null or disappear from numeric filters.

Find it:

=COUNTA(D2:D1000)-COUNT(D2:D1000)

Fix: clean the column into a helper column first, then point QUERY at the cleaned range.

Cause 8 - IMPORTRANGE is not connected yet

If QUERY(IMPORTRANGE(...)) returns an error, test IMPORTRANGE alone first. Google Sheets often needs you to allow access before the query can run.

=IMPORTRANGE(url,"Sheet1!A:D")

Once the imported data appears, wrap it with QUERY. Debugging both at once makes the error harder to read.

Cause 9 - Blank rows or repeated headers are inside the data

Exported reports often contain repeated header rows, subtotals, and blank sections. QUERY reads them as data unless your query filters them out.

=QUERY(A:D,"select A, B, D where A is not null and B <> 'Status'",1)

The best fix is a flat source table: one header row, one record per row, no merged cells, and no subtotal rows inside the calculation range.

Quick diagnostic checklist

Header rows set? Third argument is 0 or 1, not omitted Column style correct? A/B/C for normal ranges, Col1/Col2 for arrays Header names used? Use A/B/C or Col1/Col2, not visible labels Text quoted? where B = 'Paid' Dates formatted? date '2026-01-01' Mixed types? =COUNTA(D2:D1000)-COUNT(D2:D1000) IMPORTRANGE tested? Run IMPORTRANGE alone first Repeated headers? Filter out rows where header text repeats
Where SheetBrain helps: SheetBrain reads your actual sheet headers, ranges, and data types before generating or debugging formulas. The free Check tab can flag mixed text/number columns and visible formula errors; Generate and Debug can help write a QUERY formula that references your real columns instead of generic examples.

Write QUERY formulas against your real sheet

SheetBrain reads the active Google Sheet structure, then helps generate, explain, and debug formulas using your actual headers and ranges. The Check tab also scans for mixed data types and visible formula errors that often break QUERY results.

Install free on Google Workspace

TL;DR

  • Set the header argument. Use 1 for one header row and 0 for no header.
  • Use the right column style. Normal ranges use A/B; imported arrays often use Col1/Col2.
  • Do not use visible header labels as query fields. Use column references unless your formula explicitly creates those labels.
  • Quote text criteria. Use where B = 'Paid', not where B = Paid.
  • Format dates as QUERY dates. Use date 'yyyy-mm-dd'.
  • Clean mixed-type columns first. QUERY can skip or null rows when a column mixes numbers and text.
  • Use SheetBrain when you want formula help grounded in your real sheet headers, ranges, and data types.