+ Reply to Thread
Results 1 to 6 of 6

Might need SQL to do this? Group data by proximity

  1. #1
    Forum Contributor
    Join Date
    05-18-2021
    Location
    London, Ontario
    MS-Off Ver
    365
    Posts
    115

    Might need SQL to do this? Group data by proximity

    I have about 50,000 rows of wells, each has a lat/long associated with it. I want to have a square box around each well with a list of all of the other wells that are within that box. I.e. I want to have a list for each well of other wells that are close to it. For example if one is 51.9640/111.1443 and another is 51.9641/111.1461 then they would be in the same "box". Seems like this would be something that's easy to do in SQL but I'm not too familiar with it.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Might need SQL to do this? Group data by proximity

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    05-18-2021
    Location
    London, Ontario
    MS-Off Ver
    365
    Posts
    115

    Re: Might need SQL to do this? Group data by proximity

    Attached example
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Might need SQL to do this? Group data by proximity

    What is the determination for close? Two decimal places? Close in Latitude? Close in Longitude? Need to understand the criteria for what you consider close?

  5. #5
    Forum Contributor
    Join Date
    05-18-2021
    Location
    London, Ontario
    MS-Off Ver
    365
    Posts
    115

    Re: Might need SQL to do this? Group data by proximity

    Let's say if the lat and long are each within one thousandth of each other

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Might need SQL to do this? Group data by proximity

    I used power query to match the data as specified in post #5.

    1. I loaded the orginal data to the Power Query Editor. On the Data Tab, Get and Transform Data, From Range/Table
    2. In the PQE, I split the Long from the Lat and rounded each to 3 decimal places
    3. I then duplicated the query and joined them on the lat and long
    4. Removed the rounded columns from the merged query
    5. Closed and Loaded Data to Excel
    6. See attached file to review.

    I hope this works for you. You can band the rows as needed.

    The resulting file is to large to post here, so I have loaded it to Box.net. You may access it at this link

    https://app.box.com/s/6a7ob2p47f9o0d6rsjz244hemabhnro8

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Highlight Duplicates Within on Proximity/Date
    By thefrostman in forum Excel General
    Replies: 6
    Last Post: 03-06-2020, 11:27 AM
  2. Conditional Formatting for Date Proximity
    By Jeniji in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-08-2019, 09:48 PM
  3. Look-up Time Entry with closest proximity
    By moxman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2019, 05:25 AM
  4. Linear Trendline Proximity Problem
    By ih8xc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-09-2015, 07:54 PM
  5. Replies: 3
    Last Post: 01-09-2015, 02:57 PM
  6. proximity of coordinate data
    By MattRNR in forum Excel General
    Replies: 2
    Last Post: 07-18-2013, 02:41 AM
  7. Reference one cell in proximity to another
    By fadeoutagain278 in forum Excel General
    Replies: 4
    Last Post: 10-07-2008, 08:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1