Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets QUERY: How to Filter for Numbers

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To filter rows where a column contains a number in Google Sheets, use the QUERY function with a WHERE clause that checks the value is numeric, for example =QUERY(A1:C, "SELECT * WHERE B IS NOT NULL AND B >= 0") or, more reliably for mixed data, =QUERY(A1:C, "SELECT * WHERE ISNUMBER(B)") is not supported directly; instead use a helper column with ISNUMBER() or a condition like B >= 0 if all numbers are non-negative. The most robust approach is to add a helper column that returns TRUE/FALSE with =ISNUMBER(B2) and then query that column. This guide walks through the working methods, the pitfalls, and how to handle negatives, blanks, and text that looks like numbers.

What You'll Need

  • A Google account with access to Google Sheets (free).
  • A spreadsheet with data in columns, ideally with a header row in row 1.
  • Basic familiarity with typing formulas in the formula bar.
  • Decide whether your numbers can be negative; if yes, use the helper-column method rather than a simple >= 0 check.

Step-by-Step

  1. Open your sheet and identify the data range. For example, data in A1:C100 with headers in row 1. The QUERY function uses A1 notation and treats the first row as headers by default when you use SELECT *.
  2. Choose your method. There are two practical ways: (a) a helper column with ISNUMBER(), which works for any numeric value including negatives and decimals; (b) a direct condition in the QUERY string such as B >= 0 or B < 0, which only works if you know the sign range. Use (a) for mixed or unknown data.
  3. Method A – add a helper column. In an empty column next to your data (say column D), put a header in D1, for example IsNumber. In D2 enter =ISNUMBER(B2) and drag or copy down to the last row. This returns TRUE for real numbers (including dates and times, which Sheets stores as numbers) and FALSE for text, blanks, and errors.
  4. Write the QUERY formula. In an empty cell, enter =QUERY(A1:D, "SELECT A, B, C WHERE D = TRUE"). Adjust the range to include your helper column and list the columns you want. If you want all columns, use SELECT * but note that will include the helper column; to hide it, list columns explicitly or wrap the result in ARRAY_CONSTRAIN.
  5. Method B – direct numeric condition. If all your numbers are zero or positive, use =QUERY(A1:C, "SELECT * WHERE B >= 0"). This excludes blanks, text, and negatives. If you need negatives too, you cannot easily express "is a number" in a single QUERY condition without a helper column, because QUERY's language does not support ISNUMBER directly. Some users try WHERE B > -1E+100 to catch all numbers, but this is fragile and can include very large text that coerces; the helper column is safer.
  6. Test with a small range first. Copy a few rows to a new sheet and apply the formula. Check that text entries like "N/A" or "12abc" are excluded, and that numbers with decimals and negatives are included if expected.
  7. Handle blanks. If you want to exclude blanks but include zeros, the helper column ISNUMBER returns FALSE for blanks, so they are excluded automatically. If you use B >= 0, blanks are also excluded because blank is not >= 0 in QUERY's comparison. Zeros are included because 0 >= 0 is true.
  8. Format the output. QUERY returns values without the original cell formatting. If you need currency or date formats, apply them to the output range manually or use TEXT() in a helper column before querying, but that converts numbers to text and breaks numeric filtering. Better to format the result range after the query.
  9. Make it dynamic. Replace the fixed range with a named range or an open-ended range like A1:D so new rows are included automatically. Note that QUERY with an open range may include empty rows; add a condition like WHERE A IS NOT NULL to trim them.
  10. Copy the formula to other sheets or cells as needed. Use absolute references ($A$1:$D) if you plan to drag the formula.

Common Mistakes

  • Assuming QUERY supports ISNUMBER. The Google Visualization API query language used by QUERY does not have an ISNUMBER function. Writing WHERE ISNUMBER(B) returns an error or no results. Use a helper column instead.
  • Forgetting that dates and times are numbers. ISNUMBER returns TRUE for dates and times because Sheets stores them as serial numbers. If you only want plain numbers, add a check like AND(ISNUMBER(B2), NOT(ISDATE(B2))) but note ISDATE is not a built-in function; you can use CELL("type", B2)="v" combined with format checks, or simply filter by a numeric range that excludes date serials if that matters.
  • Using text-formatted numbers. If a number is stored as text (left-aligned by default), ISNUMBER returns FALSE. Convert with VALUE() or by using Format > Number after removing apostrophes.
  • Including the helper column in the output. Using SELECT * brings the helper column into the result. List columns explicitly or hide the helper column.
  • Range mismatch. The QUERY range must include the helper column. If your data is A1:C and helper is D, the range must be A1:D.
  • Header row confusion. QUERY treats the first row of the range as headers when you use SELECT *. If your data has no headers, add LABEL or use SELECT Col1, Col2 with HEADERS off? Actually QUERY always assumes headers unless you use SELECT * without a header? The safe approach: ensure row 1 contains headers.

Tips

  • Use ISNUMBER on a helper column and then QUERY that column with WHERE D = TRUE. This is the most reliable method for mixed data.
  • If you need to filter numbers in multiple columns, add one helper column per column or use a single helper with AND(ISNUMBER(B2), ISNUMBER(C2)).
  • To avoid helper columns entirely, use FILTER instead: =FILTER(A2:C, ISNUMBER(B2:B)). This is often simpler and supports ISNUMBER directly. The trade-off is that FILTER does not support SQL-like SELECT or aggregation, but for simple number filtering it is cleaner.
  • Combine QUERY with ARRAYFORMULA if you need to transform data before querying, but remember QUERY cannot see the transformed values unless they are in the sheet.
  • When sharing the sheet, protect the helper column or hide it to avoid confusion.

Troubleshooting

If your QUERY returns #VALUE! or #ERROR!, check the formula syntax: the query string must be in double quotes, and column references are by letter (A, B, C) or by Col1, Col2 if you use the SELECT Col1 style. If you see #N/A, the query returned no rows—verify your condition and that the helper column has TRUE values. If numbers are missing, check for text-formatted numbers (left-aligned) and convert them. If the output includes unexpected rows, ensure the range does not include extra columns or rows with stray data. If the formula is slow on large sheets, limit the range or use FILTER instead. If you get a parse error, look for missing commas or misplaced quotes in the WHERE clause.

Frequently Asked Questions

Can I use ISNUMBER inside a QUERY formula?

No. The QUERY function uses a query language that does not include ISNUMBER. You must use a helper column with ISNUMBER and then query that column, or use the FILTER function instead.

How do I filter numbers that are negative as well as positive?

Use a helper column with =ISNUMBER(B2) and query WHERE D = TRUE. A direct condition like B >= 0 excludes negatives.

Why are my numbers not showing up in the QUERY result?

They may be stored as text. Check alignment (text is left-aligned by default) and convert with VALUE() or by re-entering them. Also confirm the helper column returns TRUE for those cells.

Does QUERY treat dates as numbers?

Yes. Dates and times are stored as serial numbers, so ISNUMBER returns TRUE for them. If you need to exclude dates, add a condition based on the cell format or a numeric range.

Can I avoid helper columns?

Yes, use FILTER with ISNUMBER: =FILTER(A2:C, ISNUMBER(B2:B)). This is simpler for basic filtering and supports ISNUMBER natively.

What if my data has no header row?

QUERY assumes the first row is a header when you use SELECT *. Either add a header row or use SELECT Col1, Col2 with LABEL to rename, but the simplest fix is to include a header row.