0
0
Google Sheetsspreadsheet~10 mins

Why QUERY is Google Sheets' most powerful function - Formula Trace Breakdown

Choose your learning style9 modes available
Sample Data

This table shows a list of people with their 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 A, B WHERE C = 'New York' ORDER BY B DESC", 1)
Step 1: QUERY(A1:C5, "SELECT A, B WHERE C = 'New York' ORDER BY B DESC", 1)
Step 2: Filter rows where City = 'New York'
Step 3: Select columns Name (A) and Age (B) from filtered rows
Step 4: Sort the selected rows by Age descending
Step 5: Add headers from first row
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 |

Formula references range A1:C5 for data.
The QUERY function uses the data range A1:C5, which includes headers and all data rows.
Result
    E       F
1 | Name  | Age |
2 | Alice | 30  |
3 | Diana | 28  |
The QUERY formula outputs a table with only people from New York, showing their names and ages sorted by age descending.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the QUERY function filter by in this example?
ACity equals 'New York'
BAge greater than 30
CName starts with 'A'
DAll rows are included
Key Result
QUERY(data_range, "SELECT columns WHERE condition ORDER BY column", header_rows) filters, selects, and sorts data in one formula.