+ Reply to Thread
Results 1 to 10 of 10

Pull info from table of distances

  1. #1
    Registered User
    Join Date
    02-23-2022
    Location
    Sherbrooke,Can
    MS-Off Ver
    2016
    Posts
    4

    Pull info from table of distances

    Hello,

    I have a table of distances between 500 locations (title of columns are the same as title of rows).

    With min() function, I'm able to find the shortest distance, but I want to also display which city (title of columns) is the nearest for each of them. Is there a formula that can provide me that answer ?

    Also, I'm able to count the number of cities that are in a radius of 1000 km of each location, but would like to list the cities that respond to this criteria. Again, I thought that pivot tables, with the help of filters, would help me to achieve this task but haven't figured out yet.

    Trying to stay away form VBA & macros if possible !!

    Any help that you could provide ? Fictionnal data attached.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Pull info from table of distances

    The first bit is this:

    =INDEX($F$1:$N$1,MATCH(C2,F2:N2,0))

    copied down.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Pull info from table of distances

    When you say "list in another tab", exactly what do you mean? What do you want to see? Where do you want to see it?

    If you want multiple city names in E2, etc, then:


    1. Can I use VBA?

    2. If not can I use a helper column?

    3. If not what is the MAXIMUM number of cities <100 km in your real data thast would need to be concatenated into a single cell (more than about 6 and option 3 isn't really a runner.

    But if you want Toronto in a2 in another sheet/place and the cities <100 km in the column(s) next to A2, that's totally do-able.
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Pull info from table of distances

    If you are still using XL2016, as your profile states, you can use this array* formula in B2:

    =INDEX($F$1:$N$1,MATCH(MIN(IF(F2:N2>0,F2:N2,10000)),F2:N2,0))

    *Note that an array formula needs to be confirmed using the key combination of Ctrl-Shift-Enter, rather than the usual Enter.

    Copy down as required.

    Hope this helps.

    Pete

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Pull info from table of distances

    HI JMPro and welcome to the forum,

    See the attached where the formula in Column B is a Control+Shift+Enter formula. I also converted your table to another format so you could simply use a distance drop down to filter like you desire.

    Distances between cities.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Registered User
    Join Date
    02-23-2022
    Location
    Sherbrooke,Can
    MS-Off Ver
    2016
    Posts
    4

    Re: Pull info from table of distances

    Glenn wrote:

    Re: Pull info from table of distances
    The first bit is this:

    =INDEX($F$1:$N$1,MATCH(C2,F2:N2,0))

    copied down.
    ----

    AMAZING ! You're the best ... exactly what i wanted. Many thanks

  7. #7
    Registered User
    Join Date
    02-23-2022
    Location
    Sherbrooke,Can
    MS-Off Ver
    2016
    Posts
    4

    Re: Pull info from table of distances

    Quote Originally Posted by MarvinP View Post
    HI JMPro and welcome to the forum,

    See the attached where the formula in Column B is a Control+Shift+Enter formula. I also converted your table to another format so you could simply use a distance drop down to filter like you desire.

    Attachment 769691
    Hi Marvin,

    You may have the simplest & most efficient pivot table for what I was looking to get. How can I replicate that conversion (from colomn, to column & distance column) with my 500 x 500 file ?


    Thanks all for the support !

    JM
    Last edited by JMPro; 02-23-2022 at 01:46 PM.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Pull info from table of distances

    For a full formula-based solution:

    =IFERROR(INDEX($1:$1,AGGREGATE(15,6,COLUMN($F$2:$N$2)/(($F2:$N2> 0)*($F2:$N2< 1000)),COLUMNS($G13:G13))),"")

    see file.
    Attached Files Attached Files

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Pull info from table of distances

    Hi,

    There is a tool in Power Query called UnPivot that I converted your data to mine. It took about 30 seconds to do the conversion and I think you have this tool in 2016 version of Excel.
    Read about it at: https://support.microsoft.com/en-us/...5-f588221c7098
    It isn't that hard if you learn just a tad of Power Query.

    Before Power Query I had long VBA that did the same thing. I'm really glad PQ added it into their toolkit.

  10. #10
    Registered User
    Join Date
    02-23-2022
    Location
    Sherbrooke,Can
    MS-Off Ver
    2016
    Posts
    4

    Re: Pull info from table of distances

    Power Query and Unpivot are exactly what I needed here.

    Mucho gracias !! Case resolved on my end.

    JM

+ 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. [SOLVED] How to pull info from one table and use it to multiply in another table
    By JennOlsen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2020, 10:42 PM
  2. [SOLVED] Pull info from on page's table, based on the product name in that table.
    By Natejss in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-06-2019, 06:14 PM
  3. Trying to pull info from Div but cannot do so.. please help
    By ValueMyVehicles in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-31-2018, 09:43 AM
  4. Use Data Validation List To Pull Info From Table
    By hack4u in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2016, 09:20 AM
  5. Replies: 1
    Last Post: 02-10-2016, 11:26 AM
  6. Replies: 3
    Last Post: 09-19-2014, 05:43 AM
  7. [SOLVED] How to pull extra info into Pivot table report
    By MLK in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-21-2006, 08:25 PM

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