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
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!