Fix the margin
A colleague wrote a gross margin measure, and the numbers are far too high. The model has the price on each sales line and the standard cost on the product.
Margin is (price minus cost) times quantity, for every line, added up. Subtracting two column totals ignores the quantity and adds the cost of every product once per cell, whether it sold or not.
Your task
Fix the measure Gross Margin so that it returns, for every sales line, quantity times (unit price minus the product’s standard cost), added up.
About this exercise
You practise sum of products, not product of sums with SUMX and RELATED. The exercise runs on a small bike-shop model with a Sales fact table and Product, Customer and Date dimensions, the same star schema in every lesson.
Your measure, Gross Margin, fills a Power BI-style matrix grouped by Product[Category] and Customer[Segment]. As in a real report, each cell evaluates the measure in its own filter context, and the subtotals and the grand total are evaluated again in theirs rather than added up. When you check your answer, every cell is compared with the expected value, wrong cells are marked, and the hint is about the mistake you made.
Measures that already exist in the model: Sales Amount and Total Cost. Reference them in square brackets, for example [Sales Amount].
Where you start
Gross Margin = SUM(Sales[Unit Price]) - SUM(Product[Standard Cost])The result to build
| Segment | |||
|---|---|---|---|
| Category | Business | Consumer | Total |
| Accessories | 15,762.40 | 2,072.00 | 17,834.40 |
| Bikes | 82,366.00 | 14,910.00 | 97,276.00 |
| Clothing | 10,244.55 | 2,451.00 | 12,695.55 |
| Total | 108,372.95 | 19,433.00 | 127,805.95 |
Last updated 10 November 2026
Opening the exercise…