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

Rank by Date & Time

Hello, 

 

I have a dataset that I am currently ranking by Date, which is working well. However, I have multiple entries for the same day, so I would like it to assign a rank by looking at both the date & the time. Is it possible to make it look at the time stamp in my date field as well? 

 

Here is my dataset, how the rank function is currently working and how I WANT it to work in green:

 

 

exampledata.png

 

Note my actual dataset has date/time/seconds/ms for each row so each timestamp is unique. This screenshot is of an export i did into excel for display purposes.

 

Here is my rank function: 

Rank = 
VAR d = EventSignatures[DateSigned].[Date]
VAR a = EventSignatures[ActiveForm_Id]
RETURN
CALCULATE(
RANK.EQ(d, EventSignatures[DateSigned].[Date], ASC), 
FILTER(ALL('EventSignatures'),EventSignatures[ActiveForm_Id] = a)
)

 

If there is anyway to accomplish this using Rank or otherwise, I would be grateful to hear! 

 

Thanks,

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

You just need to remove ".[Date]".

Rank =
VAR d = EventSignatures[DateSigned]
VAR a = EventSignatures[ActiveForm_ld]
RETURN
    CALCULATE (
        RANK.EQ ( d, EventSignatures[DateSigned], ASC ),
        FILTER ( ALL ( 'EventSignatures' ), EventSignatures[ActiveForm_ld] = a )
    )

Rank-by-Date-Time

 

Best Regards,
Dale

Community Support Team _ Dale
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

7 REPLIES 7
Fraz707
Helper I
Helper I

Ranking_powerbi.PNG

Can you tell what modification can we do on this so that the ranking is done taking in acoount the seconds also?, as i tried the mentioned DAX and its working fine till minutes but if two records are only varying by seconds then this query ranks both of them equally. Attached a screen shot for reference, left side is the date and right side is the rank.

 

Thanks.

 

@v-jiascu-msft 

Anonymous
Not applicable

 

Hi All - relating to a similar scenario, I have the below table wherein  I want to RANK the 'SchedSTartTime' by each 'Resource' as shown in the 'desired result' column. Your help would be much appreciated. Thanks

Capture.PNG

Hi,

Write these measures

Start = SUM(Data[SchedStartTime])

Rank = RANKX(ALL(Data[Resource]),[Start])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks very much. Since i needed the results urgently, I did the below to get to the desired outcome but thanks for your time. its apprecaited.

 

1 - CONCATENATE(data[SaSchedDate].[Date],data[resource])

 

2. RankSaBySchedDateTime = VAR d = Data[SaSchedDate]
VAR a = Data[above concatenated field]
RETURN
CALCULATE (
RANK.EQ ( d, Data[SaSchedDate], ASC ),
FILTER ( ALL ( 'Data' ), data[above concatenated field] = a )
)
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

You just need to remove ".[Date]".

Rank =
VAR d = EventSignatures[DateSigned]
VAR a = EventSignatures[ActiveForm_ld]
RETURN
    CALCULATE (
        RANK.EQ ( d, EventSignatures[DateSigned], ASC ),
        FILTER ( ALL ( 'EventSignatures' ), EventSignatures[ActiveForm_ld] = a )
    )

Rank-by-Date-Time

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Oh my goodness, of course! Thank you so much. 

Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

=RANKX(ALL(EventSignatures[ActiveForm_Id]),SUM(EventSignatures[DateSigned]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.