Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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  ...
  • PC2790's avatar
    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: