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
irenelitw629
Helper II
Helper II

DAX: Identify TOP city per customer based on sales value

Hi,

I have customer, city, sales data in 3 separate tables - relationship as per attached file.

 

I want to write a DAX that can identify the Top city per customer based on the sales amount.

 

Can someone help me? I wrote a DAX to rank the city but not able to write another DAX to identify top city.

 

My DAX measure for Sales Rank=
RANKX(ALL(city), CALCULATE(sum(sales), ALLEXCEPT('customer', 'customer name)))

 

Example:

Customer NameCity Sales Top City
ASingapore $10,250,257Singapore
BParis $4,335,949Paris
BTokyo $3,691,496Paris
BNew York $ 705,351Paris

 

Thanks for your help.

Pbix: https://drive.google.com/file/d/15mNrBRl809vWkiiUxnox35Umb6XinouE/view?usp=drive_link

 

2 REPLIES 2
Anonymous
Not applicable

Hi, @irenelitw629 

You cam refer to @amitchandak reply. If it doesn't meet your needs, will you be able to re-share your PBIX file (Due to the Privacy Policy, please set do not require an account login to download the file.)

Best Regards,
Yang

Community Support Team

amitchandak
Super User
Super User

@irenelitw629 , Try index function

 

calculate(sum(sales[Sales]), keepfilters(index(1, Summarize(allselected(sales), City[City], Customer[Customer Name]), orderBy(City[City], desc) ,partitionBy(Customer[Customer Name]))))

 

Continue to explore Power BI Index function: Top/Bottom Performer by name and value- https://youtu.be/HPhzzCwe10U

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.