Forum Discussion

sirgseymour's avatar
sirgseymour
Helper I
7 years ago
Solved

Finding the difference between values on two dates the first being hte most current and the second

Hello,   I have a dataset that has a value column with an associated Timestamp column. The timestamps are not uniform so the time between any two time stamps is different. What I am trying to do is...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi sirgseymour ,

    You can try to use following measure to calculate diff between current and previous value:

    Measure =
    VAR _currDate =
        MAX ( Table[TimeStamp] )
    VAR _previous =
        CALCULATE (
            MAX ( Table[TimeStamp] ),
            FILTER ( ALLSELECTED ( Table ), [TimeStamp] < _currDate )
        )
    RETURN
        MAX ( Table[Value] ) - LOOKUPVALUE ( Table[Value], Table[TimeStamp], _previous )
    

    Regards,

    Xiaoxin Sheng