Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anam
Regular Visitor

Distance Calculation in Power BI

Hey,

I wanted to know that once I have plotted several locations on a map in Power BI, how can I calculate the distance between any two locations?

3 ACCEPTED SOLUTIONS
cs_skit
Resolver IV
Resolver IV

do you have LAT and LONG? If yes you can do it with math:

https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-h...

 

if not you need to custom call Bing Maps or Google Maps APIs for that

View solution in original post

v-sihou-msft
Employee
Employee

@Anam

 

You need Latitude and Longitude to calculate the distance between two locations with following formula:

 

=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1))*6371

 

ps: 6371 is Earth radius in km.

 

You can achieve it via either Power Query or DAX method.

 

Or you can use Google Map API as @cs_skit suggested.

 

Regards,

View solution in original post

I did a blog post on calculating the direct line distance between two points in DAX

 

http://radacad.com/dynamic-distances-in-power-bi


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

15 REPLIES 15

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.