0
0
Google Sheetsspreadsheet~10 mins

GROUP BY with aggregation in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

Sales data with names, categories, and sales amounts.

CellValue
A1Name
B1Category
C1Sales
A2Alice
B2Fruit
C210
A3Bob
B3Vegetable
C315
A4Charlie
B4Fruit
C420
A5David
B5Vegetable
C55
A6Eve
B6Fruit
C625
Formula Trace
=QUERY(A1:C6, "select B, sum(C) group by B", 1)
Step 1: QUERY(A1:C6, "select B, sum(C) group by B", 1)
Step 2: Group rows by Category: Fruit and Vegetable
Step 3: Sum Sales for Fruit: 10 + 20 + 25
Step 4: Sum Sales for Vegetable: 15 + 5
Step 5: Final output table:
Cell Reference Map
    A       B          C
1 | Name  | Category | Sales  |
2 | Alice | Fruit    | 10     |
3 | Bob   | Vegetable| 15     |
4 | Charlie| Fruit   | 20     |
5 | David | Vegetable| 5      |
6 | Eve   | Fruit    | 25     |
The formula references the range A1:C6 which contains names, categories, and sales data.
Result
    E          F
1 | Category | sum  |
2 | Fruit    | 55   |
3 | Vegetable| 20   |
The result shows each category with the total sales summed from the original data.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the QUERY formula group by?
ACategory (column B)
BName (column A)
CSales (column C)
DNo grouping
Key Result
QUERY(range, "select column, sum(column) group by column", header)