The request

From Angela Rivera, Head of Customer Support
Your goal
The Source step is October 2025's 44 returns (return_id, order_item_id, product_id, returned_on, reason, refund_amount). Merge the Products query on product_id and expand category, then group by category with returns = the number of rows and refunded = the sum of refund_amount, sorted by refunded, biggest first.
- Show exactly
categoryreturnsrefundednot done yet - 6 rows, sorted as askednot done yet
Your query steps
| return_id | order_item_id | product_id | returned_on | reason | refund_amount | |
|---|---|---|---|---|---|---|
| 1 | 1434 | 25418 | 166 | 2025-10-01 | changed_mind | 28.99 |
| 2 | 1435 | 25450 | 166 | 2025-10-02 | wrong_item | 28.99 |
| 3 | 1436 | 24641 | 154 | 2025-10-04 | changed_mind | 23.98 |
| 4 | 1437 | 25419 | 168 | 2025-10-04 | damaged | 159 |
| 5 | 1438 | 24827 | 160 | 2025-10-05 | changed_mind | 141.98 |
| 6 | 1439 | 25116 | 137 | 2025-10-05 | late | 219 |
| 7 | 1440 | 25420 | 194 | 2025-10-05 | damaged | 159 |
| 8 | 1441 | 25229 | 187 | 2025-10-06 | late | 149 |
| 9 | 1442 | 25633 | 146 | 2025-10-06 | damaged | 67.96 |
| 10 | 1443 | 25736 | 138 | 2025-10-06 | damaged | 398 |
| 11 | 1444 | 25318 | 154 | 2025-10-08 | changed_mind | 143.88 |
| 12 | 1445 | 25635 | 184 | 2025-10-09 | wrong_item | 35.98 |
| 13 | 1446 | 25230 | 177 | 2025-10-10 | changed_mind | 169 |
| 14 | 1447 | 25732 | 134 | 2025-10-11 | damaged | 185.98 |
| 15 | 1448 | 25801 | 180 | 2025-10-11 | wrong_item | 20.99 |
| 16 | 1449 | 25818 | 174 | 2025-10-12 | changed_mind | 18.99 |
| 17 | 1450 | 25746 | 162 | 2025-10-13 | wrong_item | 23.99 |
| 18 | 1451 | 25134 | 164 | 2025-10-14 | changed_mind | 52.99 |
| 19 | 1452 | 25634 | 158 | 2025-10-15 | late | 179 |
| 20 | 1453 | 25976 | 154 | 2025-10-15 | damaged | 35.97 |
| 21 | 1454 | 25820 | 171 | 2025-10-17 | changed_mind | 27.99 |
| 22 | 1455 | 25963 | 166 | 2025-10-18 | damaged | 28.99 |
| 23 | 1456 | 25995 | 198 | 2025-10-18 | damaged | 134.97 |
| 24 | 1457 | 25421 | 203 | 2025-10-19 | late | 107.98 |
| 25 | 1458 | 25978 | 128 | 2025-10-19 | wrong_item | 54.99 |
| 26 | 1459 | 25128 | 110 | 2025-10-20 | late | 179 |
| 27 | 1460 | 25293 | 193 | 2025-10-20 | changed_mind | 39.98 |
| 28 | 1461 | 26041 | 192 | 2025-10-20 | damaged | 15.99 |
| 29 | 1462 | 26114 | 122 | 2025-10-20 | damaged | 29.99 |
| 30 | 1463 | 26009 | 174 | 2025-10-21 | wrong_item | 56.97 |
| 31 | 1464 | 25975 | 218 | 2025-10-22 | wrong_item | 779 |
| 32 | 1465 | 26010 | 199 | 2025-10-22 | wrong_item | 104.99 |
| 33 | 1466 | 26040 | 184 | 2025-10-22 | damaged | 17.99 |
| 34 | 1467 | 26044 | 134 | 2025-10-22 | wrong_item | 92.99 |
| 35 | 1468 | 26193 | 171 | 2025-10-22 | wrong_item | 27.99 |
| 36 | 1469 | 26171 | 196 | 2025-10-24 | wrong_item | 25.99 |
| 37 | 1470 | 25904 | 212 | 2025-10-25 | changed_mind | 982.6 |
| 38 | 1471 | 26162 | 203 | 2025-10-25 | damaged | 323.94 |
| 39 | 1472 | 26152 | 174 | 2025-10-26 | damaged | 18.99 |
| 40 | 1473 | 26298 | 180 | 2025-10-26 | wrong_item | 20.99 |
| 41 | 1474 | 25784 | 158 | 2025-10-27 | late | 179 |
| 42 | 1475 | 25987 | 154 | 2025-10-30 | late | 11.99 |
| 43 | 1476 | 26286 | 156 | 2025-10-30 | damaged | 53.99 |
| 44 | 1477 | 26419 | 153 | 2025-10-30 | wrong_item | 72.99 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Mote fills in your answer and compares it with what the report needs.
What Angela gets, and why
The lesson
Angela’s export knows which product came back but not what kind of product it is. Two steps fix that: a merge that looks the category up, and a group by that turns 44 rows into one row per category.
Merge: look up the category
Merge queries: Products on product_id, expand category
In Power BI: select the returns query, Home → Merge Queries, choose Products as the
second table, click product_id in both previews, keep Left Outer, OK. Power Query adds a
column holding, for each return, the matching rows of Products. Click the expand icon (two
arrows) on its header, tick only category, and untick Use original column name as prefix
so the column is called category and not Products.category. Two steps are recorded:
Table.NestedJoin(Source, {"product_id"}, Products, {"product_id"}, "Products", JoinKind.LeftOuter)
Table.ExpandTableColumn(#"Merged Queries", "Products", {"category"}, {"category"})
Check the match count at the bottom of the Merge dialog: all 44 returns should find their product. A null category after expanding means a product missing from the list.
Group by: one row per category
Group by: category | returns = count rows | refunded = sum of refund_amount
In Power BI: Home → Group By (or Transform → Group By), choose Advanced to add more
than one aggregation. Group by category; first aggregation: new column name returns,
operation Count Rows; Add aggregation: refunded, operation Sum, column
refund_amount. Other operations: Average, Median, Min, Max, Count Distinct Rows, and All
Rows, which keeps the grouped rows as a nested table. Columns not grouped or aggregated are
dropped, which is what a summary is.
Table.Group(#"Expanded Products", {"category"},
{{"returns", each Table.RowCount(_), Int64.Type},
{"refunded", each List.Sum([refund_amount]), type number}})
Sort, biggest first
Sort rows: refunded descending
Click the arrow on the refunded header → Sort Descending. In a report you’d usually sort in
the visual instead; here the table itself goes to Angela.
What it shows
| category | returns | refunded |
|---|---|---|
| Outdoor | 4 | 2,193.52 |
| Lighting | 6 | 980.95 |
| Kitchen | 10 | 910.74 |
| Textiles | 14 | 684.86 |
| Decor | 9 | 683.89 |
| Furniture | 1 | 179.00 |
Textiles had the most returns, Outdoor the most money back from just four items. Bring both columns to the meeting: the count is the support team’s workload, the refund total is the cost.
Group in Power Query, or in the model?
Grouping in Power Query loads only the summary: small and fast, but nobody can drill into a single return. For a report you’d usually load all 44 rows and let a measure do the totals, so slicers on reason or date still work. Group in Power Query when the detail is never needed.
Common mistakes
- Expanding every Products column.
nameand a duplicateproduct_idclutter the table. - Sum of return_id. A sum of IDs is a meaningless number; count rows instead.
- Forgetting to rename.
CountandSumas column names mean nothing next month.
Lantern lit!
Practised: power querymerge queriesexpandgroup bycount rowssumsort rows
- Solved
- No hints
- First run
