Calculate the cost of what was sold: quantity × unit cost from the lookup table. Name the measure "Cost".
Lesson theory
The unit cost lives in the "Products" lookup table, while the quantity lives in "Sales". You need to multiply them in each sales row and add the results.
SUMX(Sales, expression)is an iterator: it walks through the visible rows of "Sales" and adds up the expression;- inside the row,
RELATED(Products[Cost])fetches the value from the lookup table through the relationship — like VLOOKUP, but without lookup formulas; - RELATED goes from the "many" side to the "one" side: from a sale to its product, not the other way around;
- writing
Sales[Qty] * Products[Price]directly in a measure is an error: a measure has no "current row".
In the trainer the model is already built: the Sales fact table on the first sheet, and the Products, Stores and Calendar lookup tables on the "Lookups" sheet. The relationships are shown in the Power Pivot panel under the sheet (expand "Data model"). The "+ Measure" button is there too: the name goes on the left, the formula on the right, and Enter saves it. Below is a PivotTable of your measures; change its rows with the "PivotTable rows" list.
The argument separator is a comma, as in English Excel (a semicolon also works if you use one throughout the formula).
Practice is part of Pro
The live spreadsheet, task checking and .xlsx files in all 170 lessons. Your progress is saved in this browser; sync across devices is coming soon.