+ Reply to Thread
Results 1 to 11 of 11

Help with VLOOKUP formula using partial matches & reference table

  1. #1
    Registered User
    Join Date
    10-22-2024
    Location
    New Jersey, USA
    MS-Off Ver
    2016
    Posts
    5

    Question Help with VLOOKUP formula using partial matches & reference table

    Hello everyone,


    I need a formula to return the appropriate value from a table based on a matching keyword. Please see screenshot:

    Screenshot 2024-10-22 155844.png

    Column "K" has a line description from which I need to pull a keyword to get a partial match. In this example, the keyword I'm looking for in cell K2 is "CMS Misc 3RD Party". On a separate sheet, I have a table (Table 13). This table has four different categories (in the "CATEGORY" column), and several keywords (in the "KEYWORD" column) which then correspond to a specific category.

    I am not sure what formula I should be using, but I came up with a VLOOKUP that I thought would work, but it's only partially working, oddly enough.

    The formula is: =VLOOKUP("*"&K2&"*",Table13,2,FALSE)

    I am using wildcards in the lookup value because the data in column "K" is random/incomplete, so I need to find partial matches by using keywords.

    For this example, the formula needs to give me an answer of "Damage", since that is the category that corresponds to the keyword "CMS Misc 3RD Party". How do I accomplish this? And is the VLOOKUP the correct formula to use?


    Thank you,

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    16,152

    Re: Help with VLOOKUP formula using partial matches & reference table

    VLOOKUP() should be acceptable, if you can give it an appropriate search string. At present, it will be searching for the first entry that contains "Nov 2023 CMS Misc 3rd Party" but none of the records in Table 13 contain that text string. If you extracted the right 18 characters from column K (for this very specific example), it should be able to find the right record =VLOOKUP(RIGHT(K2,18),Table13,2,FALSE).

    From what I see, using VLOOKUP() is appropriate. The hard part is how to extract the desired keyword search string from the longer string in column K. With only the one example given, I don't see how you intend to extract the desired search string.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    10-22-2024
    Location
    New Jersey, USA
    MS-Off Ver
    2016
    Posts
    5

    Re: Help with VLOOKUP formula using partial matches & reference table

    Hi Mr. Shorty,


    Thank you for the response. I wonder, is there a way I could do a =SEARCH formula that would tell me the correct number of characters, which I could then plug into the VLOOKUP? Like, in the formula, the Find_Text would be the list of keywords in column "A" of Table 13, and the Within_Text would be the item in cell "K2". If that were possible, I wonder if I could then take that number, and plug it into the VLOOKUP, maybe:

    =VLOOKUP("result of the SEARCH formula"&K2&"*",Table13,2,FALSE)

    Not sure of any of this makes sense, sorry (I am a beginner).


    Thank you,

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    16,152

    Re: Help with VLOOKUP formula using partial matches & reference table

    If we can come up with the requisite logic, then we should be able to program something into the formula to recognize the search string. This isn't the kind of programming I do, so I'm not good at "recognize a string within a string and extract it" kind of thing.

    My first thought based on the one example given is that the string in K2 looks like "3 character month and year and search keyword." If that is a consistent pattern, then the search keyword will always be whatever is left over after the month/year text. The month year takes up 9 characters, so the search keyword can be RIGHT(K2,LEN(K2)-9). But I can't tell based on one example if that pattern is consistent.

    We have a solid bunch of programmers here. I'm optimistic that, if you will give us enough, representative examples of the text in column K, someone will be able to come up with a way to extract the search keyword for the lookup function.

  5. #5
    Registered User
    Join Date
    10-22-2024
    Location
    New Jersey, USA
    MS-Off Ver
    2016
    Posts
    5

    Re: Help with VLOOKUP formula using partial matches & reference table

    Ok, I've attached a second screenshot with more examples. Unfortunately, the "Line description" data is carried over from a different report that contains a great deal of manually entered information, by a large group of people, and so there is no consistent pattern.

    Attachment 881579

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    16,152

    Re: Help with VLOOKUP formula using partial matches & reference table

    Invalid attachment. Make sure that you are following the procedure in yellow at the top of this page when adding attachment. An Excel file would be better than a screenshot, so that we can test out ideas on the data (most of us won't go to the trouble of hand entering data from a picture).

  7. #7
    Registered User
    Join Date
    10-22-2024
    Location
    New Jersey, USA
    MS-Off Ver
    2016
    Posts
    5

    Re: Help with VLOOKUP formula using partial matches & reference table

    Hello,


    Ok, I have tried to upload an Excel file, please see attached.

    Example for Excel Issue.xlsx

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    18,521

    Re: Help with VLOOKUP formula using partial matches & reference table

    Try pasting the following into cell A2 and then copying down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,633

    Re: Help with VLOOKUP formula using partial matches & reference table

    Alternative, using LOOKUP

    Please Login or Register  to view this content.
    Quang PT

  10. #10
    Registered User
    Join Date
    10-22-2024
    Location
    New Jersey, USA
    MS-Off Ver
    2016
    Posts
    5

    Re: Help with VLOOKUP formula using partial matches & reference table

    Hello JeteMc,


    This worked really well, thank you very much; only 165 errors in a data set 87,000 entries large.

    I believe expanding reference table 13 to include more keywords will fix many of them, but I did find one problem; I noticed that the formula will give an #N/A message when it can't reference a keyword in a line description (as it should), but sometimes it will assign a random category. For example: the keywords "transport" and "voided" are not in reference table 13, so in theory, the formula should give me an #N/A message for items with those words in the line description, correct? Currently it's categorizing them all as "Dispute" and "Per diem", respectively. I could, of course, add those words to the table, but that wouldn't fix the underlying issue. Any thoughts on what might be causing this break in the logic?

    Once again: very grateful for your help; you have saved me a lot of time and taught me so much.


    Kind regards,

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    18,521

    Re: Help with VLOOKUP formula using partial matches & reference table

    The sp in transport is found in the table.
    This issue could be resolved by replacing the SEARCH function with the FIND function to make it case sensitive, however you'll notice that at that point cell A3 will display #NUM! because in cell C3 the word Reclass has a capital R.
    I feel that the easiest solution would be to put the keyword transport in table 13 above the keyword SP as the formula will return the first match.
    I cannot replicate the issue with voided, we may be better able to help with that issue if we could see a sample file that illustrates the problem.
    Let us know if you have any questions.

+ 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. VLOOKUP Return Results With Partial Matches
    By rpalmer9 in forum Excel General
    Replies: 5
    Last Post: 05-12-2023, 05:45 PM
  2. Partial VLookup with Multiple Matches
    By guna_shekar in forum Excel Formulas & Functions
    Replies: 40
    Last Post: 04-08-2022, 10:44 PM
  3. [SOLVED] vlookup with multiple partial matches
    By richx in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-09-2019, 11:23 AM
  4. Vlookup Partial Matches HELP
    By ramanm in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2018, 07:46 AM
  5. vlookup to find partial matches
    By chris789 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-17-2018, 02:30 AM
  6. Replies: 6
    Last Post: 08-16-2013, 08:46 AM
  7. Variation of VLOOKUP that returns all partial matches
    By anthonyle in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 03-14-2013, 12:40 AM

Tags for this Thread

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