Streak 0 daysPoints 0

Lesson25/59
Fix the bugContext transition, in a bug hunt

Fix the best-customer measure

New functionsMAXX, CALCULATE
StatusNot started

The measure below should return the sales of the best customer in each cell. Instead every cell shows its own total: the biggest “customer” is the whole cell.

Inside MAXX(Customer, …) there is a row context on Customer, but a row context doesn’t filter. A bare SUMX over Sales sees every sale of the cell. Context transition (CALCULATE, or a measure reference) turns the current customer into a filter.

Your task

Fix Best Customer Sales so that it returns the highest Sales Amount of a single customer in each cell.

*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 context transition, in a bug hunt with MAXX and CALCULATE. 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, Best Customer Sales, 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].

Where you start

Best Customer Sales = MAXX(Customer, SUMX(Sales, Sales[Quantity] * Sales[Unit Price]))

The result to build

Expected result for Best Customer Sales
Year
Country20242025Total
France28,804.8520,476.0549,280.90
Germany26,623.7541,608.1568,231.90
Netherlands16,970.0527,943.3544,913.40
United Kingdom35,487.5021,506.7556,994.25
Total35,487.5041,608.1568,231.90

Last updated 10 November 2026

Opening the exercise…