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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Sofinobi
Helper IV
Helper IV

top n sales client by seller

hello all ,

please,

i have a sales table with columns : clients - sellers - amount
i have a measure to calcule the total sales [Sales]
i need to calculate the percentage of the [Sales] of the top 2 client for each seller comparing for the total sales.

 

thank you for your help
TOP N.pbix 

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Here are two measures that should do it.

 

Top2 Sales =
VAR tSummary =
    ADDCOLUMNS ( VALUES ( Sales_Tab[Client] ), "cSales", [Sales] )
RETURN
    SUMX ( TOPN ( 2, tSummary, [cSales], DESC ), [cSales] )

Not Top2 Sales =
VAR tSummary =
    ADDCOLUMNS ( VALUES ( Sales_Tab[Client] ), "cSales", [Sales] )
VAR vCount =
    COUNTROWS ( tSummary )
RETURN
    IF (
        vCount >= 4,
        SUMX ( TOPN ( vCount - 2, tSummary, [cSales], ASC ), [cSales] )
    )

 

Pat

 

Microsoft Employee

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

Here are two measures that should do it.

 

Top2 Sales =
VAR tSummary =
    ADDCOLUMNS ( VALUES ( Sales_Tab[Client] ), "cSales", [Sales] )
RETURN
    SUMX ( TOPN ( 2, tSummary, [cSales], DESC ), [cSales] )

Not Top2 Sales =
VAR tSummary =
    ADDCOLUMNS ( VALUES ( Sales_Tab[Client] ), "cSales", [Sales] )
VAR vCount =
    COUNTROWS ( tSummary )
RETURN
    IF (
        vCount >= 4,
        SUMX ( TOPN ( vCount - 2, tSummary, [cSales], ASC ), [cSales] )
    )

 

Pat

 

Microsoft Employee

thank you so much @ppm1 , it's perfect 
thanks  a lot.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.