Distance (in meter) between two coordinates in Power BI

Hi,
If I may add to the excellent contribution by @davidcenna with the Haversine formula to calculate the Great Circle distance = straight line distance.

Check out this article and example:

See the map image from a project I did in Germany, with a distance bands theme, based on his technique.

Some thoughts:

  1. You may consider to do the distance calculation in Power Query rather than in DAX, depending on the size of your model (number of calculations to make) and do a lookup in DAX.

  2. Living in Europe (the Netherlands), where we have many rivers crossing cities, the straight line distance may not always give the desired solution. Imagine 2 “nearest” points at opposite sides of a river, nearest river crossing is 5 kilometers away, this would give a bad result.
    So, if your map covers a high density area with no rivers or mountains etc, straight line distance is fine.
    If not consider driving- or walking distance for your project.

  3. Again, depending on the density, you may consider to add a “bearing” so you can identify if a “To” point is North or South etc. from the “From” location

  4. Is it just distance or also attractiveness, check out Huff gravity analysis?
    Paul

4 Likes