+ Reply to Thread
Results 1 to 5 of 5

Closest search function

  1. #1
    Registered User
    Join Date
    07-17-2019
    Location
    Lond
    MS-Off Ver
    Office365
    Posts
    2

    Closest search function

    Hi,

    New to this forum so sorry if this has been asked before.

    I am thinking about trying to write a formula/function that you can use to find what title best matches the search criteria from a list.

    For example, if I had a table looking like this:
    James Jack John Jim Jeremy
    Money 8 1 6 4 3
    Sales 10 20 40 25 40
    Call Backs 1 3 3 4 1
    Assets 30 10 20 30 20


    And I wanted to create a table that I could input various values (IE see below) and see which candidate most closely matches my inputs:
    Money 7
    Sales 25
    Call Backs 3
    Assets 20

    Then based on the formula in the excel cell I could get an answer telling me that "John" most closely matches all the criteria I inputted.

    I am thinking it would require an Index Formula with an internal Match function to identify which cell is needed, yet I am unsure the best way to work this out and then summate who most closely matches based on ALL the criteria.

    Could anyone help?

    I hope this makes sense, thanks.

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Closest search function

    =index($a$1:$f$1,aggregate(14,6,column($b$1:$f$1)*(i2=abs(b2:f2-h2))*(i3=abs(b3:f3-h3))*(i4=abs(b4:f4-h4))*(i5=abs(b5:f5-h5)),1))
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-17-2019
    Location
    Lond
    MS-Off Ver
    Office365
    Posts
    2

    Re: Closest search function

    Tim,

    Thanks for your response.

    Having a playaround with that, it seems that it only works when the inputs are 'close' to the original numbers. If I try a table with values
    6
    10
    5
    29

    Then it doesn't seem to work? Why is this?


    Also, trying to get my head around the formula. You create an arrray and then index it through the array to get the response?

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,415

    Re: Closest search function

    Hello SC16. Welcome to the forum.

    Try array entering this formula.

    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It also returns "John" with those new numbers which I believe is correct. What name are you expecting?


    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    James
    Jack
    John
    Jim
    Jeremy
    2
    Money
    8
    1
    6
    4
    3
    Money
    7
    John
    3
    Sales
    10
    20
    40
    25
    40
    Sales
    25
    4
    Call Backs
    1
    3
    3
    4
    1
    Call Backs
    3
    5
    Assets
    30
    10
    20
    30
    20
    Assets
    20


    And with new numbers


    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    James
    Jack
    John
    Jim
    Jeremy
    2
    Money
    8
    1
    6
    4
    3
    Money
    6
    John
    3
    Sales
    10
    20
    40
    25
    40
    Sales
    10
    4
    Call Backs
    1
    3
    3
    4
    1
    Call Backs
    3
    5
    Assets
    30
    10
    20
    30
    20
    Assets
    20
    Dave

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,415

    Re: Closest search function

    My mistake. The second set of numbers returns "James" but could just as easily return "John". They both have same qualification ... a tie.


    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    James
    Jack
    John
    Jim
    Jeremy
    2
    Money
    8
    1
    6
    4
    3
    Money
    6
    James
    3
    Sales
    10
    20
    40
    25
    40
    Sales
    10
    4
    Call Backs
    1
    3
    3
    4
    1
    Call Backs
    5
    5
    Assets
    30
    10
    20
    30
    20
    Assets
    29
    Last edited by FlameRetired; 07-17-2019 at 08:06 PM.

+ 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] Index/match return value row1 and value column A closest > search value
    By 323428 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-25-2018, 03:15 PM
  2. Search for closest value or greater
    By erricred in forum Excel General
    Replies: 2
    Last Post: 12-12-2017, 04:42 AM
  3. How to write in vba a search code by closest values
    By edupaulo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2017, 04:23 PM
  4. Replies: 4
    Last Post: 04-01-2015, 01:51 PM
  5. Search for a value if it matches find closest date
    By pedrojoin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2013, 08:36 AM
  6. Workbook Search and Return Closest Adjacent Numerical Value
    By maxymab in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-01-2013, 05:29 PM
  7. Replies: 1
    Last Post: 01-17-2013, 05:27 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