0
0
Google Sheetsspreadsheet~10 mins

QUERY function basics in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

This table lists people with their names, ages, and cities.

CellValue
A1Name
B1Age
C1City
A2Alice
B230
C2New York
A3Bob
B325
C3Los Angeles
A4Charlie
B435
C4Chicago
A5Diana
B528
C5New York
Formula Trace
=QUERY(A1:C5, "SELECT Col1, Col2 WHERE Col3 = 'New York'", 1)
Step 1: QUERY(A1:C5, "SELECT Col1, Col2 WHERE Col3 = 'New York'", 1)
Step 2: Filter rows where C = 'New York'
Step 3: Select columns A and B from filtered rows
Step 4: Include header row from A1:C1 for columns A and B
Step 5: Final output
Cell Reference Map
     A       B       C
1 | Name  | Age   | City     |
2 | Alice | 30    | New York |
3 | Bob   | 25    | Los Angeles |
4 | Charlie | 35  | Chicago  |
5 | Diana | 28    | New York |
The QUERY function uses the range A1:C5, which includes headers and data rows.
Result
   A      B
1 | Name | Age |
2 | Alice| 30  |
3 | Diana| 28  |
The result shows only the Name and Age of people living in New York, including the header row.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the QUERY function do in this example?
AShows all data without filtering
BSelects all columns for people older than 30
CSelects Name and Age for people living in New York
DSelects only the City column
Key Result
QUERY(range, "SELECT columns WHERE condition", header_rows) filters and returns specified columns based on a condition.