Forum Discussion
Distance Calculation in Power BI
- 9 years ago
do you have LAT and LONG? If yes you can do it with math:
if not you need to custom call Bing Maps or Google Maps APIs for that
- 9 years ago
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,
- 9 years ago
I did a blog post on calculating the direct line distance between two points in DAX
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,
- oolamide858 years agoFrequent Visitor
Can I have the distances data exported out in Excel?
- CJ73 years agoNew Member
Cant You just do euclidean distance -> sqrt((lat1-lat2)^2+(lon1-lon2)^2)*110.574 km ?
Also Why do wee need to get geocode from other sources like Google ( paid ), when power BI does locate cities on the map - therefore it could just give us direct answer regarding the longitude and latitude of certain city.