Forum Discussion

DataCruncher123's avatar
DataCruncher123
Frequent Visitor
4 years ago
Solved

Calculated Column based on three other columns

 

Hello,

 

I want to create a column (red circle) that detects when there is the same date and car type and then take the max "km stand" and substract the min "km stand" for this selections and adds it for each row. I need this for all rows and not summarized or grouped in an additional calculated table.

 

Can someone help? 🙂

 

BR

 

  • Hi,

    Here you go:

    Distance = var car = 'Car distance'[Car]
    var _date = 'Car distance'[Date] return
    var maxDistance = CALCULATE(MAX('Car distance'[KM]),all('Car distance'),'Car distance'[Date]=_date,'Car distance'[Car]=car)
    var minDistance = CALCULATE(Min('Car distance'[KM]),all('Car distance'),'Car distance'[Date]=_date,'Car distance'[Car]=car)
    return
    maxDistance-minDistance
     

     

     

     



    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/

2 Replies

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hi,

    Here you go:

    Distance = var car = 'Car distance'[Car]
    var _date = 'Car distance'[Date] return
    var maxDistance = CALCULATE(MAX('Car distance'[KM]),all('Car distance'),'Car distance'[Date]=_date,'Car distance'[Car]=car)
    var minDistance = CALCULATE(Min('Car distance'[KM]),all('Car distance'),'Car distance'[Date]=_date,'Car distance'[Car]=car)
    return
    maxDistance-minDistance
     

     

     

     



    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/