Forum Discussion
Anonymous
4 years agoNot applicable
DAX Formula
Hello everyone, I need to recover the longitude referring to the previous time stamp Here is an example of my data : Identifiant PositionTimeStampp OldPositionTimeStamp Long ...
- 4 years ago
Hey Anonymous ,
Please try this code to create new calculated column:
requiredLatValue = VAR oldtimestamp = CALCULATE ( MAX ( 'MyTable'[PositionTimestampp] ), MyTable[PositionTimeStampp] < EARLIEST ( MyTable[PositionTimeStampp] ), ALLEXCEPT ( 'MyTable', MyTable[Identifiant ] ) ) RETURN ( CALCULATE ( MAX ( MyTable[Lat] ), FILTER ( MyTable, MyTable[PositionTimeStampp] = oldtimestamp ) ) )requiredLongValue = VAR oldtimestamp = CALCULATE ( MAX ( 'MyTable'[PositionTimestampp] ), MyTable[PositionTimeStampp] < EARLIEST ( MyTable[PositionTimeStampp] ), ALLEXCEPT ( 'MyTable', MyTable[Identifiant ] ) ) RETURN ( CALCULATE ( MAX ( MyTable[Long] ), FILTER ( MyTable, MyTable[PositionTimeStampp] = oldtimestamp ) ) )The results will be as shown:
johnt75
4 years agoSuper User
You could create a couple of measures like
Old Lat =
VAR currentTimestamp =
SELECTEDVALUE ( 'TABLEPOSITION'[Position Timestamp] )
RETURN
CALCULATETABLE (
SELECTCOLUMNS (
TOPN ( 1, 'TABLEPOSITION', 'TABLEPOSITION'[Position Timestamp] ),
"@val", 'TABLEPOSITION'[Lat]
),
'TABLEPOSITION'[Position Timestamp] < currentTimestamp
)and then same again for longitude