# How to use QUERY with a text condition in Google Sheets

Put the text in single quotes inside the query: `=QUERY(A1:F13,"select A, B, F where C = 'East'",1)` returns the East orders.

**Google Sheets:** `=QUERY(A1:F13,"select A, B, F where C = 'East'",1)`

**Excel:** Excel has no QUERY function. Use FILTER with the text test: `=CHOOSECOLS(FILTER(A2:F13,C2:C13="East"),1,2,6)`.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Rep | Region | Product | Units | Revenue |
| 2026-07-03 | Ana Ruiz | East | Widget | 40 | 2080 |
| 2026-07-06 | Raj Patel | West | Gadget | 25 | 2225 |
| 2026-07-10 | Lee Chen | East | Gizmo | 12 | 1740 |
| 2026-07-14 | Ana Ruiz | North | Gadget | 30 | 2670 |
| 2026-07-17 | Kim Ortiz | West | Widget | 55 | 2860 |
| 2026-07-21 | Raj Patel | East | Widget Pro | 18 | 1422 |
| 2026-07-24 | Lee Chen | South | Gadget | 22 | 1958 |
| 2026-07-29 | Kim Ortiz | East | Gizmo | 9 | 1305 |
| 2026-08-04 | Mo Diaz | North | Gizmo | 14 | 2030 |
| 2026-08-07 | Raj Patel | South | Widget | 20 | 1040 |
| 2026-08-12 | Kim Ortiz | North | Gadget | 16 | 1424 |
| 2026-08-18 | Mo Diaz | East | Gizmo Mini | 28 | 1092 |

Formula in H1: `=QUERY(A1:F13,"select A, B, F where C = 'East'",1)`

Result (spills 6 × 3): Date, Rep, Revenue; 7/3/2026, Ana Ruiz, $2,080; 7/10/2026, Lee Chen, $1,740; 7/21/2026, Raj Patel, $1,422; 7/29/2026, Kim Ortiz, $1,305; 8/18/2026, Mo Diaz, $1,092

## 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.

## Other ways

- `=QUERY(A1:F13,"select A, B, F where C != 'East'",1)`: `!=` (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)`: `matches` takes a regular expression, so one test can accept several values. (East and West orders.)

## Common mistakes

- `where C = East` without quotes returns an error saying the column East doesn't exist.
- Text tests are case-sensitive: `'east'` doesn't match East. Use `lower(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.

## 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'`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/query-with-a-text-condition
