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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Thanks so much! It worked like a charm 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.