1. 01
  2. 02
  3. 03

Streak 0 daysPoints 0

Lesson02/59
Iterators and row context

Row by row with SUMX

New functionsSUMX
StatusNot started

There is no amount column in Sales: each line has a Quantity and a Unit Price. The amount of a line is their product, and the sales amount is the sum of those products.

SUMX(Sales, expression) walks the visible rows of Sales one by one. While it is on a row, the row context lets you read that row's Sales[Quantity] and Sales[Unit Price].

Your task

Write a measure named Sales Amount: quantity times unit price, added up over all sales lines.

*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.3No measures yet. Yours isthe first one.Key columnFact tableSALES MODEL · STAR SCHEMASHEET 1 OF 1

About this exercise

You practise iterators and row context with SUMX. 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, Sales Amount, fills a Power BI-style matrix grouped by Product[Category] 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.

Last updated 10 November 2026

Solution, expected result and common mistakes

Worked solution

Sales Amount = SUMX(Sales, Sales[Quantity] * Sales[Unit Price])

Iterators such as SUMX create a row context. Inside it, a column reference means "the value on the current row".

The expected result

Expected result for Sales Amount
Year
Category20242025Total
Accessories14,055.1513,515.7527,570.90
Bikes102,364.50107,241.50209,606.00
Clothing11,238.508,979.0520,217.55
Total127,658.15129,736.30257,394.45

Common mistakes

  • Sales Amount = SUM(Sales[Quantity]) * SUM(Sales[Unit Price])

    That multiplies two totals: all units times the sum of all prices. Multiply on each line first, then add up the lines with SUMX.

  • Sales Amount = SUM(Sales[Unit Price])

    That adds up the price of each line once, whatever the quantity. Multiply by Sales[Quantity] inside SUMX.

  • Sales Amount = SUM(Sales[Quantity]) * AVERAGE(Sales[Unit Price])

    An average price times units is close, but not exact: expensive lines with big quantities get the wrong weight. Compute each line's amount with SUMX.

Hints

  • SUM only takes a column. To add up an expression, you need the X version: SUMX(Table, Expression).
  • SUMX(Sales, Sales[Quantity] * ...) — what goes after the *?

All DAX lessons

Measure

Year
Category20242025Total
Accessories14,055.1513,515.7527,570.90
Bikes102,364.50107,241.50209,606.00
Clothing11,238.508,979.0520,217.55
Total127,658.15129,736.30257,394.45

Start typing to see your numbers.