Capstone: top N share for any metric, picked with two slicers
Combine a measure picker, a Top N parameter, TOPN and FORMAT into one sentence such as “Top 3 products: 69% of Sales”.
You will learn to
- Rank items by whichever measure a slicer picks
- Combine two parameter slicers in one measure
- Turn the result into a report-ready sentence
How it works
This capstone puts the path together. The **measure picker** (`[Selected Metric]`) decides what to measure, the **Top N** slicer decides how many products to keep, and the result becomes a sentence a manager can read in one glance.
The helper `[Top N Value]` is already in the model: it reads N with `SELECTEDVALUE('Top N'[Top N], 5)` and evaluates `[Selected Metric]` over `TOPN(n, ALL(Product[Product]), [Selected Metric])`. Because the ranking uses the picked metric, "top 3 by quantity" and "top 3 by sales" can be different products.
For the share, divide by the metric for **all** products, `CALCULATE([Selected Metric], ALL(Product[Product]))`. Customers is a distinct count, so the top products' customers are not a simple slice of the total; the share still answers "what fraction of our customers bought one of these products?". Finish with `FORMAT` and `&` to write the share and the metric name into the sentence.
Practice it hands-on with a real data model and a live report that updates as you type.
Top Region Line =
VAR best = MAXX(TOPN(1, ALL(Customer[Region]), [Total Sales]), Customer[Region])
RETURN "Best region: " & best