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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RichardT_78
Helper I
Helper I

Using Date Diff between rows

I have tried using other solutions to what appear to be the same question with many errors and no head way. 

data.PNG

My data is above which is and has been controlled by a slicer. 

I have used a RANKX measure to create 1-8 

I am trying to see the difference in seconds between each ranking number.

 

So the data will be a 0 or a number of seconds as the timestamps are repeated in blocks of 2's 

 

I think i should create 2 VAR based on the rank number and the date diff the filtered values.

 

All the time headings are measures but i also have a column in the table that can be reference to date diff from. 

 

Any help  would be apricated as i need to understand how the code archives the desired effect as this will be reused many times due to the way that the data presents itself. 

3 REPLIES 3
amitchandak
Super User
Super User

@RichardT_78 , offset can help, but for that we need any other order by column to break ties. Do you have any other column, of you can add index in power query

 

Continue to explore Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, and YOY: https://youtu.be/5YMlkDNGr0U

 

Power Query- Index Column: https://youtu.be/NS4esnCDqVw

I have got the max index for all my data 

 

RichardT_78_0-1695628900944.png

My slicer is selecting max of consist so it will show all data reported against these numbers 377104 

I then ranked them thinking i could use it as a filter 1 and 2 then timediff the time column? 

But not sure how to do this and even if it would work. 

 

Would offset compare row 1460 with 1459 which would be a different consist number? 

 

Kind Regards 

Ahh i didnt understans offset i think.

 

I have the following, but my data has many duplicate time stamps, how do i use the rank messure to allow offset to work. 

My Error keeps on returning OFFSET's Relation parameter may have duplicate rows. This is not allowed.

 

A1 Time = MAX(Events[End Date/Time])

A2 Previous Row = CALCULATE([A1 Time],OFFSET(-1,ALL(Events),ORDERBY(Events[EndDate/Time],ASC)))

A3 seconds elapsed = DATEDIFF([A1 Time],[A2 Previous Row],SECOND)+0
 
I can see what the code is doing now, many thanks in advance.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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