How to use QUERY with a text condition in Google Sheets
Google Sheets formula
=QUERY(A1:F13,"select A, B, F where C = 'East'",1)Put the text in single quotes inside the query: =QUERY(A1:F13,"select A, B, F where C = 'East'",1) returns the East orders.
- Result on the example
- a 6-row list that spills from H1 in
H1 - Excel
- See below
See it work
The formula is already in H1. Change any input and the result updates, or edit the formula to experiment.
How it works
The whole query is text in double quotes, so a text value inside it goes in single quotes: 'East'. Without them, QUERY reads East as the name of a column and returns an error. The comparison is exact and case-sensitive.
=QUERY(A1:F13,"select A, B, F where C = 'East'",1)Result{6 rows × 3 cols} "Date", "Rep", "Revenue", 46206, …
A1:F1313 rows × 6 cols: "Date", "Rep", "Region", "Product", …A range: 13 rows × 6 columns.
QUERY(A1:F13,"select A, B, F where C = 'East'",1){6 rows × 3 cols} "Date", "Rep", "Revenue", 46206, …QUERY: Runs a SQL-like query: select, where, group by, order by, limit, label.- data
A1:F1313 rows × 6 cols: "Date", "Rep", "Region", "Product", … - query
"select A, B, F where C = 'East'" - headers
1
- data
In Excel
=CHOOSECOLS(FILTER(A2:F13,C2:C13="East"),1,2,6).Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =QUERY(A1:F13,"select A, B, F where C != 'East'",1) | spills 8 × 3Different result | != (or <>) keeps every row except East. The seven orders from the other regions. |
| =QUERY(A1:F13,"select A, B, F where C matches 'East|West'",1) | spills 8 × 3Different result | matches takes a regular expression, so one test can accept several values. East and West orders. |
Common mistakes
where C = Eastwithout quotes returns an error saying the column East doesn't exist.- Text tests are case-sensitive:
'east'doesn't match East. Uselower(C) = 'east'if the data's capitals vary. - Trailing spaces in the data ("East ") stop an exact match. Use
C contains 'East'or clean the column with TRIM.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Use QUERY with a text condition
H1, use QUERY to return the Date, Rep and Revenue of every order from the East region.Questions
How do I use the value from a cell instead?
Join it into the text: "where C = '"&I1&"'". See the cell reference answer.
How do I match part of the text?
Use contains or like: where D contains 'Widget'.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine.