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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Community Champion
Community Champion

@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!:
DAX For Humans

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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