Assume you have a table with RecordID, VersionTimestamp, and VersionNumber.
Use EARLIER() or VAR with CALCULATE() to find the previous timestamp per record.
TimeDiffHours =
VAR CurrentRecord = YourTable[RecordID]
VAR CurrentTimestamp = YourTable[VersionTimestamp]
VAR PreviousTimestamp =
CALCULATE (
MAX (YourTable[VersionTimestamp]),
FILTER (
YourTable,
YourTable[RecordID] = CurrentRecord &&
YourTable[VersionTimestamp] < CurrentTimestamp
)
)
RETURN
IF (
ISBLANK (PreviousTimestamp),
BLANK(),
DATEDIFF (PreviousTimestamp, CurrentTimestamp, HOUR)
)
Power Query Approach
-
Sort the table by RecordID and VersionTimestamp.
-
Group by RecordID, then:
-
Use a custom column to subtract PreviousTimestamp from CurrentTimestamp in hours:
Duration.Hours([VersionTimestamp] - [PreviousTimestamp])