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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

DAX: Ranking in dataset based on datetime column in same dataset

Hi community,

 

I have a team members dataset about users that are part of a particular team and the created at of the user is given as a datetime column.

 

I am trying to make a custom column in DAX to give a rank to the users based on their "user_created_at" datetime in order to get an overview as to which user is the n-th person in that team.

 

The dataset looks like:

   team_id      user_id      user_created_at   
   1   a   28 sept 2022 11:30
   1   b   28 sept 2022 10:00
   1   c   28 sept 2022 12:00
   2   d   28 sept 2022 11:00
   2   e   28 sept 2022 10:00

 

I want the following outcome:

   team_id      user_id      user_created_at      rank   
   1   a   28 sept 2022 11:30   2
   1   b   28 sept 2022 10:00   1
   1   c   28 sept 2022 12:00   3
   2   d   28 sept 2022 11:00   2
   2   e   28 sept 2022 10:00   1

 

I think that I have to use RANKX() in order to obtain the answer I want. I believe that this is not a difficult question, but I couldn't figure it out DAX-wise. If anyone could maybe provide the proper DAX code would be amazing.

Thank you for your time!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1664359543927.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
achanikya
Helper I
Helper I

achanikya_0-1664361256172.png

 

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1664359543927.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Perfect, thanks a lot!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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