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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Convert dates to numbers based on chronology

Hi!

I have a simple question, but i do not know where to start.

 

I would like to convert a set of dates into numbers based on chronology. E.g. First date = 1, second date = 2

DateResult
13.01.2020 14:34:321
14.01.2020 14:34:322
15.01.2020 14:34:323
16.01.2020 14:34:324

 

PS: i have to use direct query

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

My test environment is Direct Query to connect to the SQL server, and the goal can be achieved by creating measure.

Rank = RANKX(ALL(Table_1),CALCULATE(MAX('Table_1'[Date])),,ASC,Dense)

5.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

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

Sorry to disturb you...


But did I answer your question ? Use RANKX function instead of RANK.EQ Please mark my reply as solution. Thank you very much.

 

Best Regards,
Stephen Tao

Anonymous
Not applicable

Hi! I am sorry for not replying. No, unfortunatly i got the same message saying that it does not work in direct query. However could an issue be that i also have hh/mm/ss in the date format? 

Anonymous
Not applicable

Hi @Anonymous ,

 

My test environment is Direct Query to connect to the SQL server, and the goal can be achieved by creating measure.

Rank = RANKX(ALL(Table_1),CALCULATE(MAX('Table_1'[Date])),,ASC,Dense)

5.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.

negi007
Community Champion
Community Champion

@Anonymous  simple way is to create a column based on the rank function that will give ranking to dates in your table. Dax for that column would be like below

 

Date_Rank = RANK.EQ(Date_Chornology[Date],Date_Chornology[Date],ASC)
negi007_1-1615459297980.png

 

 

 




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



Proud to be a Super User!


Follow me on linkedin

Anonymous
Not applicable

Thanks for taking the time.

This does not work for me, as i have to use direct query, and i get an error saying that RANK.EQ is not supported in direct query mode. 



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors