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
TusharGaurav
Helper III
Helper III

How to show top 3 countries based on revenue?

Hi Experts,

 

I have the following table :

TusharGaurav_0-1748498708706.png

I need to show top 3 countries with their revenue corresponding to the Product No. e.g.

TusharGaurav_1-1748498853306.png

Can you please suggest ,how I can acheive this.

 

Thanks and Regards,

Tushar Gaurav

2 ACCEPTED SOLUTIONS
Jai-Rathinavel
Super User
Super User

Hi @TusharGaurav To achieve your expected output please create Two measures as below, I have used ALLSELECTED to make the Ranking Dynamic based on filter selection. 

 

Total Revenue = MAX('Table'[Revenue]) --Replace MAX with SUM for total revenue

 

Top 3 Country Revenue = 
var _rnk = RANKX(
    ALLSELECTED('Table'[Country]),
    [Total Revenue],
    ,
    DESC,
    DENSE
)
RETURN
IF(
    HASONEVALUE('Table'[Country]),
    IF(_rnk <= 3, [Total Revenue]))

 

Input:

JaiRathinavel_0-1748500145704.png

 

Output:

JaiRathinavel_1-1748500166809.png

 

Hope it Helps 🙂 Appreciate a Kudos !

 

Thanks,

Jai Rathinavel | LinkedIn

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

mdaatifraza5556
Solution Supplier
Solution Supplier

Hi @TusharGaurav 

Can you please try the below DAX.(Create calculated table for this)

Top3ByMaxRevPerCountry =
TOPN(
    3,
    ADDCOLUMNS(
        SUMMARIZE('Table', 'Table'[Country]),
        "MaxRev", CALCULATE(MAX('Table'[revenue]))
    ),
    [MaxRev],
    DESC
)
 
 
Screenshot 2025-05-29 120043.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

6 REPLIES 6
mdaatifraza5556
Solution Supplier
Solution Supplier

Hi @TusharGaurav 

Can you please try the below DAX.(Create calculated table for this)

Top3ByMaxRevPerCountry =
TOPN(
    3,
    ADDCOLUMNS(
        SUMMARIZE('Table', 'Table'[Country]),
        "MaxRev", CALCULATE(MAX('Table'[revenue]))
    ),
    [MaxRev],
    DESC
)
 
 
Screenshot 2025-05-29 120043.png

 

If this answers your questions, kindly accept it as a solution and give kudos.

Thanks a lot for your help and prompt response

TusharGaurav
Helper III
Helper III

Hi Akash,

Thanks for your response.

However here I am not the total revenue corresponding to the country.

Here I need to show the revenue corresponding to the top product for a country, for example the total revenue for Country "C1" is 3215 but I need to show revenue corresponding to top product for this country i.e. 1110.

 

Thanks and Regards,

Tushar Gaurav

Jai-Rathinavel
Super User
Super User

Hi @TusharGaurav To achieve your expected output please create Two measures as below, I have used ALLSELECTED to make the Ranking Dynamic based on filter selection. 

 

Total Revenue = MAX('Table'[Revenue]) --Replace MAX with SUM for total revenue

 

Top 3 Country Revenue = 
var _rnk = RANKX(
    ALLSELECTED('Table'[Country]),
    [Total Revenue],
    ,
    DESC,
    DENSE
)
RETURN
IF(
    HASONEVALUE('Table'[Country]),
    IF(_rnk <= 3, [Total Revenue]))

 

Input:

JaiRathinavel_0-1748500145704.png

 

Output:

JaiRathinavel_1-1748500166809.png

 

Hope it Helps 🙂 Appreciate a Kudos !

 

Thanks,

Jai Rathinavel | LinkedIn

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks for the prompt response.

This is what I was looking for.

 

Akash_Varuna
Community Champion
Community Champion

Hi @TusharGaurav  Create a measure to calculate total revenue

Total Revenue = SUM(TableName[Revenue])

Then, create a ranking measure to rank countries.

Rank by Revenue = RANKX(ALL(TableName[Country]), [Total Revenue], , DESC)

 Add a table visual displaying Country and Total Revenue and filter it to show Rank by Revenue <= 3. 

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.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

OSZAR »