1. 01
  2. 02
  3. 03

Streak 0 daysPoints 0

Lesson01/59
SUM and the filter context of a matrix

Your first measure

New functionsSUM
StatusNot started

A measure is a formula that Power BI evaluates once for every cell of a visual. Each cell has its own filter context: the row of the matrix filters the model before the formula runs.

Here the matrix has one row per Product[Category]. The Bikes row only sees sales of bikes, so SUM adds up only their quantities. The total row sees everything.

Your task

Write a measure named Total Quantity that returns the number of units sold.

*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 sum and the filter context of a matrix with SUM. 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 Quantity, fills a Power BI-style matrix grouped by Product[Category]. 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

Total Quantity = SUM(Sales[Quantity])

You wrote the formula once; the matrix ran it four times, once per category and once for the total, each in its own filter context.

The expected result

Expected result for Total Quantity
CategoryTotal Quantity
Accessories978
Bikes189
Clothing264
Total1,431

Common mistakes

  • Total Quantity = COUNTROWS(Sales)

    That counts order lines (COUNTROWS and COUNT both do). One line can hold several units: add up the Quantity column with SUM.

  • Total Quantity = SUM(Sales[Unit Price])

    That adds up prices. The task asks for units sold, which live in Sales[Quantity].

Hints

  • Quantities live in the Sales table. Click Sales[Quantity] on the model sheet to insert it.
  • The shape is SUM(Table[Column]).

All DAX lessons

Measure

CategoryTotal Quantity
Accessories978
Bikes189
Clothing264
Total1,431

Start typing to see your numbers.