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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Calculated columns for Ranking of Customers by Distributor as well as on overall sales

I am preparing a dashboard in Power BI Desktop and have daily sales data of our distributors and their chemists. We have many distributors and every distributor have thousands of chemist (as their customers).

I want to analyse Distributor as well as Chemist wise performance and want to create two CALCULATED COLUMNS in Power BI for Ranking of Chemist within distributor as well as on overall on the basis of Sales made to them.

I will then use these ranks to create slicers for top 10, 20, 30, Chemists.

 

The sample data is attached. Please help.

 

https://www.dropbox.com/sh/ham67hhlgt0mcyn/AADHawUkp5zSId4Sm3CS9Zmwa?dl=0

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

I made changes of 2 of the columns formula:

Chemist Rank within Distributor = 

RANKX(FILTER('Table',[Distributor Code]=EARLIER('Table'[Distributor Code])),[Column],,DESC,Dense)
Overall Chemist Rank = RANKX('Table',[Column 3],,DESC,Dense)

Other 2 columns remained:

001.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Please note that I can rank the table based on values, but the result is a little bit different with yours: For example, if there 1,1 exist, the next rank number will start from 3 rather than 2. coz the second place has been replaced by 1.

13.PNG

Added four columns:

Column = SUMX(FILTER('Table (2)',[Chemist Code]=EARLIER([Chemist Code])&&[Distributor Code]=EARLIER([Distributor Code])),'Table (2)'[Value of Sales])
Chemist Rank within Distributor = 

RANKX(FILTER('Table (2)',[Distributor Code]=EARLIER('Table (2)'[Distributor Code])),[Column],,DESC)
Column 3 = SUMX(FILTER('Table (2)',[Chemist Code]=EARLIER('Table (2)'[Chemist Code])),[Value of Sales])
Overall Chemist Rank = RANKX('Table (2)',[Column 3],,DESC)

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks for your time and the effort. Actually, the ranks are not in agreement with my sample data. If a distributor have only three chemists then obviously their ranks will be 1, 2 & 3 and same is the case in over all ranking.

 

Could you please devise a solution which matches my results.

 

Regards,

 

Hi @Anonymous 

 

I made changes of 2 of the columns formula:

Chemist Rank within Distributor = 

RANKX(FILTER('Table',[Distributor Code]=EARLIER('Table'[Distributor Code])),[Column],,DESC,Dense)
Overall Chemist Rank = RANKX('Table',[Column 3],,DESC,Dense)

Other 2 columns remained:

001.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.