Forum Discussion
Spatial Join
- 6 months ago
To calculate the distance between two geograpical latitude and longitude locations using Haversine formula, you can follow the below dax pattern
FromLat = SELECTEDVALUE('From City'[lat]) FromLon = SELECTEDVALUE('From City'[lng]) ToLat = SELECTEDVALUE('To City'[lat]) Tolon = SELECTEDVALUE('To City'[lng]) Distance (km) = // Haversine/great-circle distance calculation adapted from Stack Overflow: https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula VAR __latSelected = [FromLat] VAR __lonSelected = [FromLon] VAR __radius = 6371 VAR __multiplier = PI()/180 VAR __latDiff = (KeyMeasuresTable[ToLat]-__latSelected) * __multiplier VAR __lonDiff = (KeyMeasuresTable[Tolon]-__lonSelected) * __multiplier VAR __formula1 = SIN(__latDiff/2) * SIN(__latDiff/2) + COS(KeyMeasuresTable[ToLat] * __multiplier) * COS(__latSelected * __multiplier) * SIN(__lonDiff/2) * SIN(__lonDiff/2) VAR __formula2 = 2 * ATAN(DIVIDE(SQRT(__formula1),SQRT(1-__formula1))) VAR __distance = __radius * __formula2 RETURN __distanceBy calculating the distance between the cutomer and the delivery partner as per their geo location, you will able to identify the deliver partner who is nearest to the cusotmer. I believe this way you will be able to perform the spatial join.
Connect on LinkedIn
read my blogs here: techietips.co.in
Did I answer your question? Mark my post as a solution! If I helped you, click on the Thumbs Up to give Kudos.
Proud to be a Super User!
Hi John896478,
Thank you for reaching out to the Microsoft Fabric Forum Community, and special thanks to lbendlin and tharunkumarRTK for prompt and helpful responses.
Just following up to see if the Response provided by community members were helpful in addressing the issue. if the issue still persists Feel free to reach out if you need any further clarification or assistance.
Best regards,
Prasanna Kumar