The request

From Thomas Whitaker, Head of Merchandising
Your goal
Step 1 of 3. Change quantity to a whole number and unit_price to a decimal number. The last two days' lines say pending instead of a price and become errors: remove the rows with an error in unit_price.
- Show exactly
order_idorder_dateproduct_idquantityunit_pricenot done yet - 42 rowsnot done yet
Step 2 of 3. Merge the Products query on product_id and expand its category column, so each line knows its category.
- Show exactly
order_idorder_dateproduct_idquantityunit_pricecategorynot done yet - 42 rowsnot done yet
Step 3 of 3. Add line_total = quantity × unit_price, then Group by category with revenue = the sum of line_total and units = the sum of quantity, and sort by revenue, biggest first.
- Show exactly
categoryrevenueunitsnot done yet - 6 rows, sorted as askednot done yet
Step 1 · your sheet
| order_id | order_date | product_id | quantity | unit_price | |
|---|---|---|---|---|---|
| 1 | 10809 | 2025-09-02 | 145 | 1 | 10.99 |
| 2 | 10809 | 2025-09-02 | 175 | 2 | 84.99 |
| 3 | 10809 | 2025-09-02 | 193 | 1 | 19.99 |
| 4 | 10819 | 2025-09-03 | 171 | 2 | 27.99 |
| 5 | 10819 | 2025-09-03 | 156 | 1 | 53.99 |
| 6 | 10819 | 2025-09-03 | 139 | 1 | 189.00 |
| 7 | 10819 | 2025-09-03 | 121 | 3 | 31.99 |
| 8 | 10819 | 2025-09-03 | 106 | 2 | 229.00 |
| 9 | 10824 | 2025-09-03 | 186 | 1 | 20.99 |
| 10 | 10829 | 2025-09-03 | 133 | 1 | 51.99 |
| 11 | 10829 | 2025-09-03 | 182 | 1 | 17.99 |
| 12 | 10829 | 2025-09-03 | 146 | 1 | 16.99 |
| 13 | 10830 | 2025-09-03 | 142 | 1 | 38.99 |
| 14 | 10830 | 2025-09-03 | 153 | 4 | 72.99 |
| 15 | 10830 | 2025-09-03 | 190 | 3 | 43.99 |
| 16 | 10830 | 2025-09-03 | 141 | 1 | 13.99 |
| 17 | 10830 | 2025-09-03 | 171 | 1 | 27.99 |
| 18 | 10837 | 2025-09-04 | 161 | 1 | 219.00 |
| 19 | 10837 | 2025-09-04 | 173 | 1 | 139.00 |
| 20 | 10837 | 2025-09-04 | 166 | 1 | 28.99 |
| 21 | 10845 | 2025-09-06 | 136 | 2 | 159.00 |
| 22 | 10845 | 2025-09-06 | 126 | 1 | 379.00 |
| 23 | 10845 | 2025-09-06 | 166 | 4 | 28.99 |
| 24 | 10845 | 2025-09-06 | 203 | 2 | 53.99 |
| 25 | 10845 | 2025-09-06 | 171 | 2 | 27.99 |
| 26 | 10852 | 2025-09-06 | 163 | 1 | 139.00 |
| 27 | 10862 | 2025-09-07 | 146 | 1 | 16.99 |
| 28 | 10862 | 2025-09-07 | 154 | 1 | 11.99 |
| 29 | 10867 | 2025-09-08 | 145 | 1 | 10.99 |
| 30 | 10880 | 2025-09-09 | 145 | 1 | 10.99 |
| 31 | 10891 | 2025-09-10 | 164 | 1 | 52.99 |
| 32 | 10894 | 2025-09-10 | 166 | 1 | 28.99 |
| 33 | 10904 | 2025-09-12 | 203 | 1 | 53.99 |
| 34 | 10904 | 2025-09-12 | 119 | 1 | 259.00 |
| 35 | 10904 | 2025-09-12 | 122 | 2 | 29.99 |
| 36 | 10909 | 2025-09-12 | 175 | 1 | 84.99 |
| 37 | 10909 | 2025-09-12 | 194 | 1 | 159.00 |
| 38 | 10909 | 2025-09-12 | 128 | 1 | 54.99 |
| 39 | 10919 | 2025-09-13 | 182 | 2 | 17.99 |
| 40 | 10919 | 2025-09-13 | 185 | 1 | 12.99 |
| 41 | 10919 | 2025-09-13 | 180 | 2 | 20.99 |
| 42 | 10919 | 2025-09-13 | 146 | 4 | 16.99 |
| 43 | 10929 | 2025-09-14 | 122 | 1 | pending |
| 44 | 10933 | 2025-09-14 | 156 | 2 | pending |
| 45 | 10934 | 2025-09-14 | 178 | 3 | pending |
| 46 | 10937 | 2025-09-14 | 135 | 1 | pending |
| 47 | 10937 | 2025-09-14 | 170 | 1 | pending |
| 48 | 10953 | 2025-09-15 | 111 | 1 | pending |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each row of the result that matches becomes a firefly in your lantern.
Step 2 · your sheet
| order_id | order_date | product_id | quantity | unit_price | |
|---|---|---|---|---|---|
| 1 | 10809 | 2025-09-02 | 145 | 1 | 10.99 |
| 2 | 10809 | 2025-09-02 | 175 | 2 | 84.99 |
| 3 | 10809 | 2025-09-02 | 193 | 1 | 19.99 |
| 4 | 10819 | 2025-09-03 | 171 | 2 | 27.99 |
| 5 | 10819 | 2025-09-03 | 156 | 1 | 53.99 |
| 6 | 10819 | 2025-09-03 | 139 | 1 | 189.00 |
| 7 | 10819 | 2025-09-03 | 121 | 3 | 31.99 |
| 8 | 10819 | 2025-09-03 | 106 | 2 | 229.00 |
| 9 | 10824 | 2025-09-03 | 186 | 1 | 20.99 |
| 10 | 10829 | 2025-09-03 | 133 | 1 | 51.99 |
| 11 | 10829 | 2025-09-03 | 182 | 1 | 17.99 |
| 12 | 10829 | 2025-09-03 | 146 | 1 | 16.99 |
| 13 | 10830 | 2025-09-03 | 142 | 1 | 38.99 |
| 14 | 10830 | 2025-09-03 | 153 | 4 | 72.99 |
| 15 | 10830 | 2025-09-03 | 190 | 3 | 43.99 |
| 16 | 10830 | 2025-09-03 | 141 | 1 | 13.99 |
| 17 | 10830 | 2025-09-03 | 171 | 1 | 27.99 |
| 18 | 10837 | 2025-09-04 | 161 | 1 | 219.00 |
| 19 | 10837 | 2025-09-04 | 173 | 1 | 139.00 |
| 20 | 10837 | 2025-09-04 | 166 | 1 | 28.99 |
| 21 | 10845 | 2025-09-06 | 136 | 2 | 159.00 |
| 22 | 10845 | 2025-09-06 | 126 | 1 | 379.00 |
| 23 | 10845 | 2025-09-06 | 166 | 4 | 28.99 |
| 24 | 10845 | 2025-09-06 | 203 | 2 | 53.99 |
| 25 | 10845 | 2025-09-06 | 171 | 2 | 27.99 |
| 26 | 10852 | 2025-09-06 | 163 | 1 | 139.00 |
| 27 | 10862 | 2025-09-07 | 146 | 1 | 16.99 |
| 28 | 10862 | 2025-09-07 | 154 | 1 | 11.99 |
| 29 | 10867 | 2025-09-08 | 145 | 1 | 10.99 |
| 30 | 10880 | 2025-09-09 | 145 | 1 | 10.99 |
| 31 | 10891 | 2025-09-10 | 164 | 1 | 52.99 |
| 32 | 10894 | 2025-09-10 | 166 | 1 | 28.99 |
| 33 | 10904 | 2025-09-12 | 203 | 1 | 53.99 |
| 34 | 10904 | 2025-09-12 | 119 | 1 | 259.00 |
| 35 | 10904 | 2025-09-12 | 122 | 2 | 29.99 |
| 36 | 10909 | 2025-09-12 | 175 | 1 | 84.99 |
| 37 | 10909 | 2025-09-12 | 194 | 1 | 159.00 |
| 38 | 10909 | 2025-09-12 | 128 | 1 | 54.99 |
| 39 | 10919 | 2025-09-13 | 182 | 2 | 17.99 |
| 40 | 10919 | 2025-09-13 | 185 | 1 | 12.99 |
| 41 | 10919 | 2025-09-13 | 180 | 2 | 20.99 |
| 42 | 10919 | 2025-09-13 | 146 | 4 | 16.99 |
| 43 | 10929 | 2025-09-14 | 122 | 1 | pending |
| 44 | 10933 | 2025-09-14 | 156 | 2 | pending |
| 45 | 10934 | 2025-09-14 | 178 | 3 | pending |
| 46 | 10937 | 2025-09-14 | 135 | 1 | pending |
| 47 | 10937 | 2025-09-14 | 170 | 1 | pending |
| 48 | 10953 | 2025-09-15 | 111 | 1 | pending |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each row of the result that matches becomes a firefly in your lantern.
Step 3 · your sheet
| order_id | order_date | product_id | quantity | unit_price | |
|---|---|---|---|---|---|
| 1 | 10809 | 2025-09-02 | 145 | 1 | 10.99 |
| 2 | 10809 | 2025-09-02 | 175 | 2 | 84.99 |
| 3 | 10809 | 2025-09-02 | 193 | 1 | 19.99 |
| 4 | 10819 | 2025-09-03 | 171 | 2 | 27.99 |
| 5 | 10819 | 2025-09-03 | 156 | 1 | 53.99 |
| 6 | 10819 | 2025-09-03 | 139 | 1 | 189.00 |
| 7 | 10819 | 2025-09-03 | 121 | 3 | 31.99 |
| 8 | 10819 | 2025-09-03 | 106 | 2 | 229.00 |
| 9 | 10824 | 2025-09-03 | 186 | 1 | 20.99 |
| 10 | 10829 | 2025-09-03 | 133 | 1 | 51.99 |
| 11 | 10829 | 2025-09-03 | 182 | 1 | 17.99 |
| 12 | 10829 | 2025-09-03 | 146 | 1 | 16.99 |
| 13 | 10830 | 2025-09-03 | 142 | 1 | 38.99 |
| 14 | 10830 | 2025-09-03 | 153 | 4 | 72.99 |
| 15 | 10830 | 2025-09-03 | 190 | 3 | 43.99 |
| 16 | 10830 | 2025-09-03 | 141 | 1 | 13.99 |
| 17 | 10830 | 2025-09-03 | 171 | 1 | 27.99 |
| 18 | 10837 | 2025-09-04 | 161 | 1 | 219.00 |
| 19 | 10837 | 2025-09-04 | 173 | 1 | 139.00 |
| 20 | 10837 | 2025-09-04 | 166 | 1 | 28.99 |
| 21 | 10845 | 2025-09-06 | 136 | 2 | 159.00 |
| 22 | 10845 | 2025-09-06 | 126 | 1 | 379.00 |
| 23 | 10845 | 2025-09-06 | 166 | 4 | 28.99 |
| 24 | 10845 | 2025-09-06 | 203 | 2 | 53.99 |
| 25 | 10845 | 2025-09-06 | 171 | 2 | 27.99 |
| 26 | 10852 | 2025-09-06 | 163 | 1 | 139.00 |
| 27 | 10862 | 2025-09-07 | 146 | 1 | 16.99 |
| 28 | 10862 | 2025-09-07 | 154 | 1 | 11.99 |
| 29 | 10867 | 2025-09-08 | 145 | 1 | 10.99 |
| 30 | 10880 | 2025-09-09 | 145 | 1 | 10.99 |
| 31 | 10891 | 2025-09-10 | 164 | 1 | 52.99 |
| 32 | 10894 | 2025-09-10 | 166 | 1 | 28.99 |
| 33 | 10904 | 2025-09-12 | 203 | 1 | 53.99 |
| 34 | 10904 | 2025-09-12 | 119 | 1 | 259.00 |
| 35 | 10904 | 2025-09-12 | 122 | 2 | 29.99 |
| 36 | 10909 | 2025-09-12 | 175 | 1 | 84.99 |
| 37 | 10909 | 2025-09-12 | 194 | 1 | 159.00 |
| 38 | 10909 | 2025-09-12 | 128 | 1 | 54.99 |
| 39 | 10919 | 2025-09-13 | 182 | 2 | 17.99 |
| 40 | 10919 | 2025-09-13 | 185 | 1 | 12.99 |
| 41 | 10919 | 2025-09-13 | 180 | 2 | 20.99 |
| 42 | 10919 | 2025-09-13 | 146 | 4 | 16.99 |
| 43 | 10929 | 2025-09-14 | 122 | 1 | pending |
| 44 | 10933 | 2025-09-14 | 156 | 2 | pending |
| 45 | 10934 | 2025-09-14 | 178 | 3 | pending |
| 46 | 10937 | 2025-09-14 | 135 | 1 | pending |
| 47 | 10937 | 2025-09-14 | 170 | 1 | pending |
| 48 | 10953 | 2025-09-15 | 111 | 1 | pending |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each row of the result that matches becomes a firefly in your lantern.
What Thomas gets, and why
The lesson
One export, three steps, every two weeks
This boss level is the whole chapter in one query. Thomas wants revenue and units by category, biggest first, every two weeks, without anyone redoing the work. That is what a query is for: the steps you add today replay on every future file.
As in the rest of the chapter, you are in the practice editor, not Power Query itself. Each step’s starter carries the steps you already wrote, the way Applied Steps keep growing in Excel.
The source has 48 lines from September 1 to 15, 2025: order_id, order_date, product_id,
quantity and unit_price. The export wrote everything as text, and the marketplace hadn’t
priced the last two days yet, so 6 lines say pending.
Step 1: types and errors
Change type: quantity to whole number
Change type: unit_price to decimal
Remove errors: unit_price
After the second step, the 6 pending cells show Error: text that can’t become a number.
In Excel’s editor the thin bar under the column header turns partly red, and clicking an Error
cell shows the reason (“We couldn’t convert to Number”). Home → Remove Rows → Remove Errors drops
those rows: 42 remain.
Removing rows is a decision, not housekeeping. Here it is right, because those lines have no price
yet and the next report will include them. Say so in the note you send: “Sept 14–15 marketplace
lines are not priced yet and are excluded.” When errors come from a data problem instead (a
price typed as 12,99), fix the value with Replace Values before changing the type rather than
throwing the line away.
In M:
#"Changed Type" = Table.TransformColumnTypes(Source, {{"quantity", Int64.Type}, {"unit_price", type number}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"unit_price"})
Change the second type right after the first and Excel asks whether to replace the current step or add a new one; Replace keeps both in one step, as above. The practice editor keeps one line per column.
Step 2: the category lookup
Merge queries: Products on product_id, expand category
The export only knows product ids. Products holds the name and category of every product that
appears in it. A left outer merge on product_id adds the category to each of the 42 lines. All
of them match. A null category would mean a new product missing from the list, and its revenue
would land in a “null” group in the next step.
Step 3: totals by category
Add column: line_total = [quantity] * [unit_price]
Group by: category | revenue = sum of line_total | units = sum of quantity
Sort rows: revenue descending
In Excel: Home → Group By → Advanced, group by category, then add one aggregation per
row: revenue = Sum of line_total, units = Sum of quantity. The M:
Table.Group(#"Added Custom", {"category"},
{{"revenue", each List.Sum([line_total]), type number},
{"units", each List.Sum([quantity]), Int64.Type}})
The result is six rows, one per category.
Load it, chart it, refresh it
Home → Close & Load To… gives you the choice:
| Load to | Use it when |
|---|---|
| Table on a new sheet | you want the grouped table itself, for a chart or a formula |
| PivotTable Report | you’d rather load the 42 lines and summarise them in a PivotTable (skip Group by) |
| Only Create Connection | another query uses this one (like Products here) |
For Thomas, load the grouped table and insert a bar chart (Insert → Charts → Clustered Bar) on revenue: categories are long labels and bars read best sorted, which the query already did. Or load the 42 lines and build a PivotTable with category in Rows and revenue in Values; then add a PivotChart. Both give the same numbers.
In two weeks, save the new CSV over the old one and press Data → Refresh All. The query
re-imports, re-types, removes the new pending lines, merges and groups; the table and the chart
update. If the new file has a new product, refresh Products too (Refresh All does both).
What can you conclude?
Textiles leads with 1,160.83 from 20 units, but Lighting is only 11.90 behind with 11 units: the two are tied for any practical purpose. Furniture makes 717.00 from just 3 units, and Kitchen sells 17 units for 545.83. Revenue and units tell different stories, so show both, and say above the chart what it leaves out (the unpriced lines).
Common mistakes
- Changing both columns to decimal: quantities should be whole numbers, and a decimal type hides
data problems like
2.5units. - Removing errors across all columns when only
unit_priceis expected to fail: a new problem elsewhere would silently delete rows. - Grouping on
unit_priceinstead ofline_total: the sum of prices ignores quantities. - Forgetting the sort: the numbers are right, but the chart reads in a random order.
Lantern lit!
Practised: power querychange typeremove errorsmerge queriescustom columngroup byrefresh
- Solved
- No hints
- First run
