Forum Discussion
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] returnvar 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)returnmaxDistance-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
Community Champion
Hi,
Here you go:Distance = var car = 'Car distance'[Car]var _date = 'Car distance'[Date] returnvar 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)returnmaxDistance-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/- DataCruncher123Frequent Visitor
Thanks for quick support, it works now 🙂