cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lwklwk98
Helper I
Helper I

DAX Help - RANKX

Hi PowerBi Community!

 

I am having an issue with writing a DAX to create a column to rank the values of the overall sales table.

 

Company2020 Sales2020 Rank2021 Sales2021 Rank2022 Sales2022 Rank
A10,000,000110,000,00017,000,0002
B5,500,00021,500,0004800,0005
C1,000,00045,000,000210,000,0001
D5,000,00031,000,00051,000,0004
E700,00053,000,00035,000,0003

 

The dataset I have is the problem since it shows multiply entries of Sales for each company. (Each company has 5-10 Sales entries.)

The values in the above table are total yearly Sales and PowerBI has kindly categorized and sum them for each company.

 

 I searched online and I found solutions that asked me to use Rankx but those works for tables with only singular entries. Is there any way in PowerBi to achieve the ranking for multiple entries?

 

Thank you so much! Any help or alternative solution to achieve similar results will be appreciated!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@lwklwk98 , is 2020 sales is column or 2020 is year as row

 

You need create a measure 

sales  = sum(Table[2020 sales])

 

Rank 2020 = rankx(all(Table[company]), [sales],,desc)

 

if sales is just a column same rank will work across year

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@lwklwk98 , is 2020 sales is column or 2020 is year as row

 

You need create a measure 

sales  = sum(Table[2020 sales])

 

Rank 2020 = rankx(all(Table[company]), [sales],,desc)

 

if sales is just a column same rank will work across year

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

@amitchandak 

 

Thanks so much! It worked like a charm 🙂

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.