Forum Discussion

Nicci's avatar
Nicci
Icon for Helper I rankHelper I
2 years ago
Solved

Get total miles driven in a table

Hi Everyone, I have a table in power bi which is rows for each driving trip users enter. They only enter the ending mileage of the car. What I need to do is show in the table how many total miles dr...
  • lbendlin's avatar
    lbendlin
    2 years ago

    Here is one example using a measure. Frankly, this could be a calculated column too.

     

     

     

  • lbendlin's avatar
    lbendlin
    2 years ago

    I think a calculated column can solve a lot of your issues.

     

    Try this:

     

    Eff. Mileage = 
    var em = [Ending Mileage]
    var veh = [VehicleID]
    var pem = maxx(filter(all(Mileage),[VehicleID]=veh && [Ending Mileage]<em),[Ending Mileage])
    return em-COALESCE(pem,RELATED(Vehicles[StartingMileage]))