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...
I have two Postcodes columns | From {W2} To {W3} Greg_Deckler
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.
- Greg_Deckler6 years agoCommunity Champion
MYDATASTORY - Oh, I will have to take a look at the PBIX. Here I was busy creating a couple of Quick Measures for you that I just published out to the Quick Measure gallery. Here they are:
ATAN2 - https://community.powerbi.com/t5/Quick-Measures-Gallery/ATAN2/td-p/963263
Going the Distance - https://community.powerbi.com/t5/Quick-Measures-Gallery/Going-the-Distance/m-p/963267#M423
I'll take a look at your PBIX.
- MYDATASTORY6 years agoResolver I
Greg_Deckler Wow this is great and appreciated, have a look at the file.