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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
joshua1990
Post Prodigy
Post Prodigy

RANK by DateTime Column

Hi experts!

 

How is it possible to get a rank column based on a DateTime column?

 

1 ACCEPTED SOLUTION

Hi, 

For duplicates we can modify the last optional parameter of RANKX e.g.

Dense:

ValtteriN_0-1672661749515.png

 

Skip:

ValtteriN_1-1672661791639.png

 

In addition to this we can add an index column to the table and use that as a secondary ranking:

Dax:

Column =
var _dateR =
RANKX('Table (15)',value('Table (15)'[Column1]),'Table (15)'[Column1],ASC,Dense) return
var _indexR =
RANKX('Table (15)',value('Table (15)'[Index]),'Table (15)'[Index],ASC,Dense) return

_dateR+_indexR


For ranking column add this:
Rank = RANKX('Table (15)',VALUE('Table (15)'[Column]),,DESC)


End result (change DESC to ASC to match your use case):
ValtteriN_0-1672665210067.png

 











Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Column = RANKX('Calendar',value('Calendar'[Date]),'Calendar'[Date],DESC)
ValtteriN_0-1672652003582.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ValtteriN : Thanks a lot! Does this work with duplicates? It seems like not. How can we add this aspect into the function?

Hi, 

For duplicates we can modify the last optional parameter of RANKX e.g.

Dense:

ValtteriN_0-1672661749515.png

 

Skip:

ValtteriN_1-1672661791639.png

 

In addition to this we can add an index column to the table and use that as a secondary ranking:

Dax:

Column =
var _dateR =
RANKX('Table (15)',value('Table (15)'[Column1]),'Table (15)'[Column1],ASC,Dense) return
var _indexR =
RANKX('Table (15)',value('Table (15)'[Index]),'Table (15)'[Index],ASC,Dense) return

_dateR+_indexR


For ranking column add this:
Rank = RANKX('Table (15)',VALUE('Table (15)'[Column]),,DESC)


End result (change DESC to ASC to match your use case):
ValtteriN_0-1672665210067.png

 











Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.