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!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I am trying to create a matrix visual that will show the top 10 customers by sales, but then also show the gross margin dollars and percent for each of those customers. I also need to be able to drill down and show the products purchased by each of those customers. I have seen many related help topics that explain how to do this if you only have the sales column showing, but adding the margin columns seems to add additional complexity.
I have the following metric which gives me the ranking that I can use to find the top 10, and am pretty sure that somehow I will need to add a filter somewhere to limit just those customers to show, but am not sure exactly what to do at that point.
Metric = RANKX( ALL( 'Sales Data'[Customer Name] ), CALCULATE( [Total Sales] ), , DESC, Dense )
Could someone help me with what to do next and how to apply the correct filters?
Thank you so much for your help.
@StevenHiatt , You can use measures like
M1= calculate([Sales], keepfilters(topn(10, allselected(Table[Customer Name]), [Sales], desc) )
In drill report use the measure as filter or add measures like
M2= calculate([Margin %], keepfilters(topn(10, allselected(Table[Customer Name]), [Sales], desc) )
All measures in visual should use the keepfilter topn
or use topn visual level filter
TOPN: https://youtu.be/QIVEFp-QiOk
Learn Power BI: RANKX, TOPN, Dynamic TOPN with Numeric Parameters: https://youtu.be/cN8AO3_vmlY?t=25610
Thanks Amit, this is very helpful. I added the sales metric and it only shows the top 10 customers as expected. However, when I try to drill down to show all the products for that customer it will only show some of the products, not all. I'm guessing it is only showing the top 10 products? How can I get it to show all products, but just for those top 10 customers?
Here is a screenshot of where I am now:
The first column is a metric of total sales. The second column in the TOPN formula you gave me, which shows correctly at the customer level, but omits totals at the product level (orange area). The last column is a ranking which works correctly at the customer level, but not at the product level. I want the area in red to show 4 (the customer rank) and the green area should be blank as there were no sales of those products in the period.
_Customer Top 10 =
CALCULATE( [Chosen Sales MTD3],
KEEPFILTERS(
TOPN( 10, ALLSELECTED( 'Sales Data'[Customer Name] ), [Chosen Sales MTD3], DESC )
)
)
_Rank Test =
RANKX(
ALLSELECTED('Sales Data'[Customer Name]),
[Chosen Sales MTD3]
)
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 50 | |
| 49 | |
| 35 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 92 | |
| 75 | |
| 41 | |
| 26 | |
| 25 |