Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I have a bit of a complicated question about calculating distances across rows. I wanted to see if you can help out. First, I will explain the data and goal then go over an example of what I'm trying to do.
Sample data
Journey | Event | Vehicle | Event | Time | Latitude | Longitude |
123 | 1 | 555 | Disconnected | 07/11/2020 19:00:12 | 51 | 5.6 |
123 | 2 | 444 | Disconnected | 07/11/2020 19:00:12 | 51 | 5.5 |
123 | 3 | 333 | Disconnected | 07/11/2020 19:01:12 | 51 | 5.3 |
123 | 4 | 555 | Restored | 07/11/2020 19:21:05 | 51 | 5.5 |
999 | 5 | 888 | Disconnected | 09/11/2020 11:07:03 | 51 | 5.7 |
999 | 6 | 777 | Disconnected | 09/11/2020 11:07:50 | 51 | 5.4 |
999 | 7 | 888 | Restored | 09/11/2020 11:14:36 | 51 | 5.5 |
999 | 8 | 777 | Restored | 09/11/2020 11:17:26 | 51 | 5.6 |
We have multiple journeys which contain multiple events that occur on different vehicles. Each event has a time it was created as well as coordinates of where it was created.
Goal
What I need to do: whenever there is a "Disconnected" event, I need to know what the distance of that vehicle is with the other vehicles and show the maximum of those distances.
Important
Example with sample data
Does anyone have any ideas?
Solved! Go to Solution.
Hi @sem1 ,
According to your description, create the data and set the formula rule to [latitude] + [longitude].
1. Create Measure.
Measure =
var _table=GENERATE(SELECTCOLUMNS(FILTER(ALL('Table'),[Journey]=MAX([Journey])),"jo1",[Journey],"Type",[Vehicle],"juli",[Longitude]+[Latitude]),SELECTCOLUMNS(FILTER(ALL('Table'),[Journey]=MAX([Journey])),"jo2",'Table'[Journey],"Type2",[Vehicle],"juli2",[Longitude]+[Latitude]))
var _value=
MAXX(_table,ABS([juli]-[juli2]))
return
IF(MAX('Table'[Event.1])="Disconnected",_value,BLANK())
2. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @sem1 ,
According to your description, create the data and set the formula rule to [latitude] + [longitude].
1. Create Measure.
Measure =
var _table=GENERATE(SELECTCOLUMNS(FILTER(ALL('Table'),[Journey]=MAX([Journey])),"jo1",[Journey],"Type",[Vehicle],"juli",[Longitude]+[Latitude]),SELECTCOLUMNS(FILTER(ALL('Table'),[Journey]=MAX([Journey])),"jo2",'Table'[Journey],"Type2",[Vehicle],"juli2",[Longitude]+[Latitude]))
var _value=
MAXX(_table,ABS([juli]-[juli2]))
return
IF(MAX('Table'[Event.1])="Disconnected",_value,BLANK())
2. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
92 | |
86 | |
85 | |
66 | |
49 |
User | Count |
---|---|
140 | |
113 | |
106 | |
64 | |
60 |