Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
StevenHiatt
Frequent Visitor

How to Show Top 10 Customers by Sales, with Extra Details

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 = RANKXALL'Sales Data'[Customer Name] ), CALCULATE[Total Sales] ), DESCDense )

 

Could someone help me with what to do next and how to apply the correct filters?

 

Thank you so much for your help.

3 REPLIES 3
amitchandak
Super User
Super User

@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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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:

StevenHiatt_0-1699482445166.png

 

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]
    )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.