DAX Top N Sales (Incl. Others) Measure

Keeps the top N items visible and preserves the grand total, so a chart can add an "Others" bucket for the rest.

Ranking and Top NAdvancedtop nothersbucketgrouping

DAX code

Top N Sales (Incl. Others) =
VAR TopCount = 5
VAR CurrentRank = [Rank by Sales]
RETURN
    IF(
        HASONEVALUE('Product'[ProductName]),
        IF(CurrentRank <= TopCount, [Total Sales], BLANK()),
        [Total Sales] -- keeps the grand total row intact so a chart's "Others" slice can be its remainder
    )

Notes

This measure alone hides non-top-N products at the row level while keeping the grand total correct. To actually label the rest "Others" on a chart axis, pair it with a calculated column that groups everything outside the top N under one text value.

Requirements

Builds on these measures

How to use this measure

  1. In Power BI Desktop, select the table that should hold the measure and choose New measure on the ribbon.
  2. Paste the code, then replace the placeholder table and column names with your own. The My table names fields above do this for you.
  3. Run it through the DAX Formatter if you want it laid out in your team's style.

Related DAX measures

More DAX resources

Browse all 175 measures in the Power BI DAX Measures Library, or search the library for something similar to Top N Sales (Incl. Others).