Forum Discussion
GKJARC
2 years agoResolver I
Get previous row's value
Hi all, I'm looking for a way get the timestamp of the previous row onto the current row. So that when they're on the same row, I can calculate the time difference for each user. Example: ...
- 2 years ago
Hi,
Please check the below picture and the attached pbix file.
OFFSET function (DAX) - DAX | Microsoft Learn
Previous CC = SELECTCOLUMNS ( OFFSET ( -1, Data, ORDERBY ( Data[Timestamp], ASC ), , PARTITIONBY ( Data[UserID] ), MATCHBY ( Data[UserID], Data[Timestamp] ) ), Data[Timestamp] )Diff CC = IF ( NOT ISBLANK ( Data[Previous CC] ), Data[Timestamp] - Data[Previous CC] )
Jihwan_Kim
2 years agoSuper User
Hi,
Please check the below picture and the attached pbix file.
OFFSET function (DAX) - DAX | Microsoft Learn
Previous CC =
SELECTCOLUMNS (
OFFSET (
-1,
Data,
ORDERBY ( Data[Timestamp], ASC ),
,
PARTITIONBY ( Data[UserID] ),
MATCHBY ( Data[UserID], Data[Timestamp] )
),
Data[Timestamp]
)
Diff CC =
IF ( NOT ISBLANK ( Data[Previous CC] ), Data[Timestamp] - Data[Previous CC] )