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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak 

 

Thanks so much! It worked like a charm 🙂

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.