Level 1Preview: Sheets SuperpowersProject, 6 min
Ask your data questions with QUERY
The task
A preview of Level 3. QUERY lets you ask a whole table a question in plain words, like a database. You'll write one QUERY in H1 and sharpen it four times.
- Total sales by regionIn H1, type
=QUERY(A1:E31, "select C, sum(E) group by C"). Column letters name the columns, and the result fills in with its own headers. - Biggest region firstEdit H1 so the biggest region comes first: add
order by sum(E) descto the end of the query. - The three biggest dealsReplace the query with one that lists the three biggest deals over $1,000:
=QUERY(A1:E31, "select A, B, E where E > 1000 order by E desc limit 3") - A report with real column namesLast one. Deals and revenue per rep, with readable headers:
=QUERY(A1:E31, "select B, count(A), sum(E) group by B order by sum(E) desc label count(A) 'Deals', sum(E) 'Revenue'")
The data
The starting sheet. Cells outlined in green are where your formulas go.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Order | Rep | Region | Product | Amount | |||
| 2 | 4001 | Theo | South | Enterprise | $1,040 | |||
| 3 | 4002 | Maya | South | Starter | $105 | |||
| 4 | 4003 | Jonah | West | Starter | $655 | |||
| 5 | 4004 | Theo | West | Enterprise | $1,295 | |||
| 6 | 4005 | Priya | Central | Starter | $455 | |||
| 7 | 4006 | Maya | West | Pro | $405 | |||
| 8 | 4007 | Jonah | South | Pro | $170 | |||
| 9 | 4008 | Priya | South | Enterprise | $2,490 | |||
| 10 | 4009 | Theo | South | Starter | $635 | |||
| 11 | 4010 | Jonah | South | Starter | $310 | |||
| 12 | 4011 | Maya | South | Starter | $270 | |||
| 13 | 4012 | Theo | Central | Pro | $305 | |||
| 14 | 4013 | Theo | Central | Starter | $720 | |||
| 15 | 4014 | Priya | East | Pro | $315 | |||
| 16 | 4015 | Priya | South | Enterprise | $2,280 | |||
| 17 | 4016 | Maya | West | Starter | $340 | |||
| 18 | 4017 | Priya | South | Pro | $185 | |||
| 19 | 4018 | Jonah | Central | Pro | $335 | |||
| 20 | 4019 | Jonah | East | Pro | $560 | |||
| 21 | 4020 | Jonah | South | Enterprise | $1,115 | |||
| 22 | 4021 | Theo | West | Starter | $415 | |||
| 23 | 4022 | Priya | West | Starter | $615 | |||
| 24 | 4023 | Jonah | East | Enterprise | $1,730 | |||
| 25 | 4024 | Maya | Central | Pro | $760 | |||
| 26 | 4025 | Jonah | East | Starter | $550 | |||
| 27 | 4026 | Maya | South | Enterprise | $1,505 | |||
| 28 | 4027 | Priya | West | Pro | $480 | |||
| 29 | 4028 | Theo | South | Starter | $780 | |||
| 30 | 4029 | Theo | South | Pro | $425 | |||
| 31 | 4030 | Priya | East | Pro | $365 |