Forum Discussion
Henrique_Quint
Helper I
1 year agoDistance (in kilometers) between adresses
Hello everyone, I'm currently in a pickle, I have two tables. One that has all my stores info and their adresses The other one has delivery adresses for every sale. What I want to do is c...
- 1 year ago
You can use the Haversine formula to calculate the distance between two geo coordinates (must be a pair of latitude and longitude).
Distance in KM = // Haversine Formula VAR EarthRadiusKm = 6371.0 VAR Lat1 = RADIANS ( SELECTEDVALUE ( 'FromLocation'[Latitude] ) ) VAR Lat2 = RADIANS ( SELECTEDVALUE ( ToLocation[Latitude] ) ) VAR Lon1 = RADIANS ( SELECTEDVALUE ( 'FromLocation'[Longitude] ) ) VAR Lon2 = RADIANS ( SELECTEDVALUE ( ToLocation[Longitude] ) ) VAR DeltaLat = Lat2 - Lat1 VAR DeltaLon = Lon2 - Lon1 VAR a = POWER ( SIN ( DIVIDE ( DeltaLat, 2 ) ), 2 ) + COS ( Lat1 ) * COS ( Lat2 ) * POWER ( SIN ( DIVIDE ( DeltaLon, 2 ) ), 2 ) VAR c = 2 * ASIN ( SQRT ( a ) ) RETURN EarthRadiusKm * c
Anonymous
1 year agoNot applicable
Hi Henrique_Quint,
we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.
Regards,
Vinay Pabbu