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 September 15. Request your voucher.

Reply
jaanvikhatter
New Member

How to handle Duplicate Rankings Using the RANKX DAX Function (No unique identifier)

Hello Everyone,

I have a data where i don't have any unique identifier, and i want to give the data a unique ranking, even for the rows where i have ID and dates as duplicated.

 

For example, in the table i have an ID column and a Date column where values can be duplicated. I am trying to create a Rank column but i am getting same rank for the rows where ID and Dates are same (as shown under column Rank). Required Output is the column how i want Ranking to be.

jaanvikhatter_0-1739301101711.png

 

I have tried the following measure

RANKX(
    FILTER(
        'Table',
        'Table'[ID] = EARLIER('Table'[ID])
    ),
    'Table'[Date],
    ,
    DESC
)

 

Thanks!! 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is creating index column in power query editor.

I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1739334395294.png

 

let
    Source = data_source,
    #"Sorted Rows" = Table.Sort(Source,{{"date", Order.Ascending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"id"}, {{"date", each Table.AddIndexColumn(_, "new rank", 1,1)}}),
    #"Expanded date" = Table.ExpandTableColumn(#"Grouped Rows", "date", {"date", "new rank"}, {"date", "new rank"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded date",{{"date", type date}, {"new rank", Int64.Type}})
in
    #"Changed Type"

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
AntrikshSharma
Super User
Super User

@jaanvikhatter Is this a Global Rank or a Local Rank that resets for each ID? Are you trying to use this column in any other calculation? What is it? Running Total? Maybe you won't even need this column.

Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is creating index column in power query editor.

I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1739334395294.png

 

let
    Source = data_source,
    #"Sorted Rows" = Table.Sort(Source,{{"date", Order.Ascending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"id"}, {{"date", each Table.AddIndexColumn(_, "new rank", 1,1)}}),
    #"Expanded date" = Table.ExpandTableColumn(#"Grouped Rows", "date", {"date", "new rank"}, {"date", "new rank"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded date",{{"date", type date}, {"new rank", Int64.Type}})
in
    #"Changed Type"

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.