Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculate difference between values in same column

  I need to calculate the difference in mileages and quantity, to calculate the fuel consumption per vehicle and date. Can someone please help me? 
  • Anonymous's avatar
    Anonymous
    2 years ago

    I found the solution! 

     

    thought I'd share it with you, sice you've all been so helpfull. 

    Gereden km's tussen tankbeurten =
    VAR CurrentVehicle = 'F: Tankgegevens'[Voertuignummer]
    VAR CurrentDate = 'F: Tankgegevens'[Datum]
    VAR CurrentKM = 'F: Tankgegevens'[KM-stand]

    VAR PreviousKM =
    CALCULATE(
    MAX('F: Tankgegevens'[KM-stand]),
    FILTER(
    'F: Tankgegevens',
    'F: Tankgegevens'[Voertuignummer] = CurrentVehicle &&
    'F: Tankgegevens'[Datum] < CurrentDate
    )
    )

    RETURN
    IF(
    NOT ISBLANK(PreviousKM),
    CurrentKM - PreviousKM,
    BLANK()
    )