QUERY Function in Google Sheets: Syntax, Examples & Compatibility
Learn how to filter and summarize a data table with Google Visualization query language in Google Sheets. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Google Sheets. How formula examples are checked
Quick answer: filter and summarize a data table with Google Visualization query language in Google Sheets. The reproducible examples below use explicit values so the formula’s meaning is testable without a large workbook.
Evidence: The function name and syntax are documented in the linked vendor function reference. Expected outputs were independently reasoned or checked outside the application. These are not native Google Sheets test results. A guide being published here does not certify every software release or file-import scenario.
Syntax and arguments
=QUERY(data, query, [headers])
data is the input table; the second argument is a quoted query string using column letters or Col1-style names depending on the range.
Best use case: Filter and summarize a data table with Google Visualization query language.
Set up the example sheet
Enter this sample range in A1:C5, including the headings:
| A: Item | B: Team | C: Amount |
|---|---|---|
| Pen | East | 10 |
| Pad | West | 20 |
| Box | East | 30 |
| Pen | East | 5 |
Enter the formula in an unused cell. For a formula returning several values, leave an unobstructed area where those values can expand. These formulas use comma argument separators in a typical English-language locale; commas or semicolons inside quoted text are data, not argument separators. Adapt the separator if your regional settings require it.
Worked example 1: QUERY with known input
=QUERY(A1:C5,"select A,C where B = 'East'",1)
Expected output: a two-column table containing rows Pen,10, Box,30, Pen,5.
The condition keeps only East team rows, and the select clause returns item and amount.
Worked example 2: a second QUERY case
=QUERY(A1:C5,"select A,C where C > 15",1)
Expected output: two rows Pad,20 and Box,30.
The numeric condition selects only amounts above 15.
Compare both results before replacing literal values or short sample ranges with your own workbook data. For a spilling formula, compare every output cell, not only the top-left result.
Practical advice and troubleshooting
When this formula helps: Use QUERY when you want a compact filtering and grouping pipeline. Use FILTER instead for direct Boolean conditions and formula-based criteria.
Important edge case: A query string has its own quoting rules: text conditions need single quotes inside the double-quoted Sheets formula string. Mixed-type columns can cause unexpected null-like values.
If the result differs, first verify the text-versus-number types of the input cells, the argument separators for your locale, and the range size. For dynamic arrays, inspect occupied cells in the output area. An error that looks like a missing function may reflect a software version rather than incorrect data.
Compatibility and version considerations
Excel does not have a native QUERY worksheet function with this signature; Power Query and FILTER/SORT functions solve different parts of the problem.
Check your installed release for availability and dynamic-array support.
Function availability and parameter behavior must be judged for the specific application and release; a function documented in one spreadsheet does not automatically work in another.
Related guides and official documentation
-
Google Sheets documentation for QUERY — function syntax and current vendor information.
Editorial verification: Vendor catalogue referenced as of 2026-10-12. The two example outputs are independently reasoned; no native application run, screenshot, or version-specific output is claimed. Review the editorial testing standards if you require stronger proof before importing a workbook.