Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I have an example table below with lat/longs, what I'm trying to figure out is there a way to input unique lat/longs and have that calculate the distance to the lat/long in the table below. Thanks again for the help.
| Reception | Latitude | Longitude |
| CARLSBADR | 32.46959 | -104.137 |
| CARR | 40.88491 | -104.867 |
| CASPER | 42.85017 | -106.351 |
| CBEAUMONT | 30.04742 | -94.0736 |
| CDICKINSN | 29.46067 | -95.0451 |
| CHANNELVW | 29.76388 | -95.1027 |
| CHARENTON | 29.87393 | -91.5207 |
| CHEROKEE | 36.7986 | -98.3595 |
| CHILDRESS | 34.38211 | -100.263 |
| CHINAGR | 32.52974 | -100.821 |
Solved! Go to Solution.
@Anonymous
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 (6371 is Earth radius in km.)
For your requirement there are also Power Query or DAX method.
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Be careful! The accepted answer does not include the step of converting Degrees to Radians. You will get a very different answer if you do not convert to radians.
The final formula should be:
=ACOS((SIN(RADIANS(Lat1)) * SIN(RADIANS(Lat2))) + (COS(RADIANS(Lat1)) * COS(RADIANS(Lat2))) * (COS(RADIANS(Lon2) - RADIANS(Lon1)))) * 6371
This calculates distance (in kilometers) between two points on the surface of the Earth as a sphere.
Also note:
Use Google Earth.
Not terribly helpful... . One set of points? Sure. But if you have 50 and you want the top 5 shortest? User won't wait while you run that api 50 times to determine the shortest.
@Anonymous
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 (6371 is Earth radius in km.)
For your requirement there are also Power Query or DAX method.
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Thank you very much for your information.
However, I wonder the distance is a straight line distance between two points or a curved distance on the Earth?
I would like to appreciate very much if you can anwser this question.
I have used the following as reference in the past
https://dataveld.com/2019/03/20/display-points-within-a-distance-radius-on-a-power-bi-map/
That's actually pretty slick as well but won't work for what I'm trying to accomplish. I need to input certain lat/longs in then calculate the distance to the closest reception point.
You can either hardcode in the Haversine formula (or other formula) to calculate distance from lat/long inputs, or you could use a web api to send the lat/log for start and finish to get the distance.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Are you saying send the points to a service that calculates the distance using street maps? Otherwise, using a web service to run a simple Haversine, et. al., makes little sense.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.