Calculate closest distance among multiple points.

vicpinto1970

New Member
Joined
Sep 27, 2021
Messages
1
Office Version
  1. 365
I have a data set with thousands of rows of unique locations that include a LAT and LON. For each row, I would like to calculate the closest location in relation to all the other locations and store this data in a new set in the form of LOCATION - CLOSEST LCOATION - DISTANCE. I created some VBA code to do this but the problem is my data set contains thousands of rows and it takes the code about 11 minutes to run. Too slow.

I was wondering if a combination of power query and power pivot could speed things up.

Any thought?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the Forum.

I realise you asked for a PQ solution, but this kind of thing can be done in Excel with formulas. Check out this post in this Forum to see if it helps at all. There are dozens of other posts here if you search for keyword "longitude".



The formula to calculate distances between two locations on a sphere is key to it all. It's called the Grate Circle Distance.

Great-circle distance - Wikipedia
BlueMM: Excel formula to calculate distance between 2 latitude, longitude (lat/lon) points (GPS positions)
Latitude And Longitude
 
Upvote 0

Forum statistics

Threads
1,223,698
Messages
6,173,901
Members
452,536
Latest member
Chiz511

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top