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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PBI_newuser
Post Prodigy
Post Prodigy

Top 3 Clients based on Amount by Country

Hi, how to show only top 3 clients by count based on the amount? I used below measure but it doesn't work.

Sample here.

Rank - by Country by Client =
IF (
    ISINSCOPE ( D_Client[Client]),
    RANKX (
        CALCULATETABLE (
            VALUES (   D_Client[Client] ),
            ALLSELECTED (   D_Client[Client] )
        ),
        SUM('Table'[Amount])
    )

)

Expected output:

CountryClientAmountRank - by Country by Client
AUC-16157111
AUC-22488352
AUC-3605603
HKC-373498001
HKC-35672382
HKC-38486843
IDC-711528281
IDC-721306722
IDC-73339823
KHC-803064161
KHC-812528292
KHC-821435563
LAC-82736931
LAC-83230462
LAC-11056463
MMC-1151512171
MMC-116352972
MMC-117282823
MYC-8316647641
MYC-4216072662
MYC-12815776193
NZC-1284231151
NZC-1802205492
NZC-1811313503
SGC-2233016381
SGC-502402922
SGC-2241805943
THC-1145607301
THC-1335123052
THC-2284680163
TWC-833639781
TWC-311266492
TWC-109253563
VNC-1086285401
VNC-823907132
VNC-1373118033
1 ACCEPTED SOLUTION
tharunkumarRTK
Super User
Super User

@PBI_newuser 

Here is one way to achieve the result 

 

Top3 countries =
var result = RANK(DENSE, SUMMARIZE(ALLSELECTED('Table'),'Table'[Country],D_Client[Client]) , ORDERBY(CALCULATE(SUM('Table'[Amount])),desc), ,PARTITIONBY('Table'[Country]))
return IF(result <=3 , result)
 
 

If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun


View solution in original post

4 REPLIES 4
tharunkumarRTK
Super User
Super User

@PBI_newuser 

Here is one way to achieve the result 

 

Top3 countries =
var result = RANK(DENSE, SUMMARIZE(ALLSELECTED('Table'),'Table'[Country],D_Client[Client]) , ORDERBY(CALCULATE(SUM('Table'[Amount])),desc), ,PARTITIONBY('Table'[Country]))
return IF(result <=3 , result)
 
 

If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun


Thanks @tharunkumarRTK , it works!

zenisekd
Super User
Super User

Hi, could you try: 
Top3ClientsByCountry =
VAR RankedClients = ADDCOLUMNS ( SUMMARIZE ( Sales, Sales[Country], "RankedClients", TOPN ( 3, SUMMARIZE ( FILTER ( Sales, Sales[Amount] > 0 ), Sales[Client], "TotalAmount", SUM(Sales[Amount]) ), [TotalAmount], DESC ) ), "Client", [RankedClients] )
RETURN RankedClients


Kudos and mark as solution appreciated 🙂

Hi @zenisekd , thank you for your suggested solution but  it doesn't work.

PBI_newuser_1-1708930227185.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.