Forum Discussion

GKJARC's avatar
GKJARC
Resolver I
2 years ago
Solved

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: ...
  • Jihwan_Kim's avatar
    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] )