Top N customers in each region, chosen with a slicer

Let report users pick 3, 5 or 10 on a slicer and show the sales of that many top customers in every region, with a safe default when several values are selected.

You will learn to

  • Read a number from a disconnected parameter table with SELECTEDVALUE
  • Give SELECTEDVALUE a default for when several values are selected
  • Use a TOPN table of customers as a CALCULATE filter

How it works

A **parameter table** is a small table with no relationships. The `'Top N'` table holds the values 3, 5 and 10. A slicer on it doesn’t filter any sales, but a measure can read the choice and use it.

`SELECTEDVALUE('Top N'[Top N])` returns the selected number when exactly one value is selected, and blank otherwise (nothing or several values picked). Give it a second argument, `SELECTEDVALUE('Top N'[Top N], 5)`, and it falls back to 5 instead of blank, so the visual never goes empty.

Then use the number as TOPN’s first argument. `TOPN(N, VALUES(Customer[Customer]), [Total Sales])` is a table of the N customers with the most sales in the current context, and passed to CALCULATE it becomes a filter. Because VALUES respects the row, the North row gets North’s own top N. `ALL(Customer)` would pick the company-wide top N and, as a table filter, override the region.

Practice it hands-on with a real data model and a live report that updates as you type.

Top N Product Sales =
VAR N = SELECTEDVALUE('Top N'[Top N], 3)
RETURN CALCULATE([Total Sales], TOPN(N, VALUES(Product[Product]), [Total Sales]))