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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

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

@amitchandak 

 

Thanks so much! It worked like a charm 🙂

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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