How to get seconds time difference from a DateTime Column in Dax?

Viewed 24

I have a table which has a DateTime column, status column and an index column, I am trying to get a column that shows the time difference in seconds between the previous row and the current row and for it to ignore the previous row if status is blank.

This is what the table looks like, currently:

Time                     ID        status.     timesinceprev(seconds)          index 
22.1.21 04:02:04         12         low                  0                       1
22.1.21 04:24:07         12         low                1320                      2
22.1.21 04:26:04         12         medium             120                       3
22.1.21 04:29:04         12                             180                      4
22.1.21 04:30:05         12         low                 61                       5 
22.1.21 04:31:07         12                             62                       6 

I want my timesinceprev column to display a 0 in the row if status has nothing there

timesinceprev = 
var values = IF(DATEDIFF(LOOKUPVALUE('Table'[Time],'Table'[index],'Table'[index]-1),'Table'[Time],MINUTE)>720,
0,
IF(ISBLANK(FILTER('Table','Table'[index]=EARLIER('Table[index])-1)),
0,
DATEDIFF(LOOKUPVALUE('Table'[Time],'Table'[index],'Table'[index]-1),'Table'[Time],MINUTE)
* 60)) 
 
   return values
0 Answers
Related