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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
PimK
Frequent Visitor

Rank column based on other text column

Hi all,

 

See below table, where I have a column Code (text) and a column Name. The aim is to rank the column Name based on the column Code. When column Name doesn't have a unique value, take the minimum of column Code. Column Code doesn't have duplicates. Like this:

 

CodeNameRank
01.00D1
01.01D1
01.02A2
01.03B3
01.04D1
01.05B3

 

How can I achieve this?

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @PimK ,

 

Since you don't want to change the Code column as number type. You need to first create column to return number type values.

vstephenmsft_0-1693968966512.png

Then create a column to return min code value group by name.

vstephenmsft_1-1693969413578.png

At last, create the ranking column.

vstephenmsft_2-1693969445671.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @PimK ,

 

Since you don't want to change the Code column as number type. You need to first create column to return number type values.

vstephenmsft_0-1693968966512.png

Then create a column to return min code value group by name.

vstephenmsft_1-1693969413578.png

At last, create the ranking column.

vstephenmsft_2-1693969445671.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Thanks Stephen!

Greg_Deckler
Super User
Super User

@PimK Maybe: 

Rank = RANKX( 'Table', [Name],,,Dense )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you for the reply Greg.

 

The code you mentioned sorts on the column Name instead of the column Code.. 

The rank position for name A should be 2. Your code results in 3 as rank position for name A.

 

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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