Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Trying to build a customer performance view where a slicer controls the Top N value. The matrix should display the Top N customers by sales and then show a single Others row that groups all remaining customers. Total Sales and a What If parameter for selecting N already exist. Guidance is needed on writing DAX that returns the Top N customers correctly, calculates Others as the remaining sales, and keeps the matrix total showing the full combined amount without breaking the visual layout.
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below.
Sales: =
SUM(sales[sales])
Top N sales: =
VAR _topN = [prm_top_N Value]
VAR _topNtable =
WINDOW (
1,
ABS,
_topN,
ABS,
ALL ( Customer[customer] ),
ORDERBY ( [Sales:], DESC )
)
VAR _topNsales =
CALCULATE ( [Sales:], KEEPFILTERS ( _topNtable ) )
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( Customer[customer] ) = "Others",
CALCULATE ( [Sales:], REMOVEFILTERS ( Customer[customer] ) )
- CALCULATE ( [Sales:], _topNtable ),
HASONEVALUE ( Customer[customer] ), _topNsales,
[Sales:]
)
You can handle Top N plus an Others row using two measures and a display logic measure.
Top N Customers
Others Sales
Label Measure
Use Customer Label in the matrix rows
Use TopN Customers as the value
Add Others Sales as a second value
Matrix total will show full sales, Top N will show individually, and Others will neatly group the rest.
You can handle Top N plus an Others row using two measures and a display logic measure.
Top N Customers
Others Sales
Label Measure
Use Customer Label in the matrix rows
Use TopN Customers as the value
Add Others Sales as a second value
Matrix total will show full sales, Top N will show individually, and Others will neatly group the rest.
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below.
Sales: =
SUM(sales[sales])
Top N sales: =
VAR _topN = [prm_top_N Value]
VAR _topNtable =
WINDOW (
1,
ABS,
_topN,
ABS,
ALL ( Customer[customer] ),
ORDERBY ( [Sales:], DESC )
)
VAR _topNsales =
CALCULATE ( [Sales:], KEEPFILTERS ( _topNtable ) )
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( Customer[customer] ) = "Others",
CALCULATE ( [Sales:], REMOVEFILTERS ( Customer[customer] ) )
- CALCULATE ( [Sales:], _topNtable ),
HASONEVALUE ( Customer[customer] ), _topNsales,
[Sales:]
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 11 | |
| 9 | |
| 6 | |
| 6 |