Forum Discussion
How to Calculate Distance on map from one Postcode to Another Postcode
- 6 years ago
Greg_Deckler Wow this is fantastic, let me have a good look at it tomorrow so I can accept the solution , I'll let you know, but definitely amazing...
You will need something like the Google Maps API. https://www.youtube.com/watch?v=IGr5oQLm0ls
Not sure what your data looks like, just zip codes? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
- MYDATASTORY6 years agoResolver I
I have two Postcodes columns | From {W2} To {W3} Greg_Deckler
- Greg_Deckler6 years agoCommunity Champion
Right so your basic formula for short distances is:
dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth)So you could do it (with lots of caveats in terms of the accuracy of the output of the above formula since the Earth isn't a perfect sphere) if you had the longitudes and latitudes of those zip codes.
- MYDATASTORY6 years agoResolver I
Greg_Deckler Thanks for the update, any chance you can have at the look at the PBix file updated with (hyperlink) as see how will be the best way to add the calculation based on the data. Much appreciated in advance.