1. 01
  2. 02
  3. 03

Streak 0 daysPoints 0

Lesson03/59
RELATED inside an iterator

Reading across a relationship

New functionsRELATED
StatusNot started

The cost of a product lives in Product[Standard Cost], one row per product. Sales lines only store a ProductKey.

Inside SUMX(Sales, ...) you have a row context on Sales. RELATED(Product[Standard Cost]) follows the relationship from that sales line to its product and returns the cost. It works from the many side (*) to the one side (1).

Your task

Write a measure named Total Cost: for each sales line, quantity times the product's standard cost, added up.

*1*1*1*1SALEST1 · 420 ROWSSalesKeyNUMOrder DateDATEShip DateDATEProductKeyNUMCustomerKeyNUMQuantityNUMUnit PriceNUMPRODUCTT2 · 8 ROWSProductKeyNUMProductTEXTCategoryTEXTColorTEXTList PriceNUMStandard CostNUMCUSTOMERT3 · 10 ROWSCustomerKeyNUMCustomerTEXTCountryTEXTSegmentTEXTDATET4 · 731 ROWSDateDATEYearNUMQuarterTEXTMonthTEXTMonth NumberNUMNOTES1Filters flow from 1 to *, alongthe arrow: Product filters Sales.2Select a column or a measureto insert it at the cursor.3Measures in this model:[Sales Amount]Key columnFact tableSALES MODEL · STAR SCHEMASHEET 1 OF 1

About this exercise

You practise related inside an iterator with 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, Total Cost, fills a Power BI-style matrix grouped by Customer[Country] and Date[Year]. 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. Reference them in square brackets, for example [Sales Amount].

Last updated 10 November 2026

Solution, expected result and common mistakes

Worked solution

Total Cost = SUMX(Sales, Sales[Quantity] * RELATED(Product[Standard Cost]))

RELATED reads one value from the one side of a relationship, for the row you are iterating.

The expected result

Expected result for Total Cost
Year
Country20242025Total
France15,650.0011,552.5027,202.50
Germany18,421.5026,710.5045,132.00
Netherlands11,295.0014,769.0026,064.00
United Kingdom18,386.0012,804.0031,190.00
Total63,752.5065,836.00129,588.50

Common mistakes

  • Total Cost = SUM(Product[Standard Cost])

    That adds up the cost list once per product. Customers and years do not filter Product, so every cell shows the same number. Iterate Sales and read the cost with RELATED.

  • Total Cost = SUMX(Sales, RELATED(Product[Standard Cost]))

    Close: this counts each line's cost once. A line with 3 units costs three times as much. Multiply by Sales[Quantity].

  • Total Cost = SUM(Sales[Quantity]) * SUM(Product[Standard Cost])

    That multiplies two unrelated totals. Do the multiplication per sales line with SUMX(Sales, ...).

Hints

  • Start like Sales Amount: SUMX(Sales, Sales[Quantity] * ...).
  • Sales[...] can't see Product columns directly. Wrap the cost in RELATED( ).

All DAX lessons

Measure

Year
Country20242025Total
France15,650.0011,552.5027,202.50
Germany18,421.5026,710.5045,132.00
Netherlands11,295.0014,769.0026,064.00
United Kingdom18,386.0012,804.0031,190.00
Total63,752.5065,836.00129,588.50

Start typing to see your numbers.