Excel - hierarchical lookup columns

Posted on 2014-08-01
Last Modified: 2014-08-02
What are the best approaches to accomplish a hierarchical lookup in excel.
What I mean is, first find the matching main category and then based on that find all subcategory matches that belong to the main category.

So for example, suppose I have a some rows of text in Worksheet1 Col A each of which has embedded within the text a brand name and a product name. e.g. "Dell laptop computers are great" or " HP laserjet printers print fast". Dell and HP would be the main categories and computer and printer would be subcategories.

And suppose I have some lookup lists in another worksheet, Worksheet2.
Worksheet2 Col A holds brand names (unique list no repeating values e.g. Dell, HP, Apple). Worksheet2 Cols B and C hold product category in Col B and product name in Col C - brand names would be a repeating field, product name would be unique and the combination of the two would be unique and tie a product to a brand) e.g. Dell Laptop, Dell Desktop, Dell Tablet, HP Laserjet, HP Inkjet, HP Thermal

Back on Worksheet1, I want to search Worksheet 1 Col A for the occurrence of a matching product category from Worksheet2 Col A and display that in Worksheet1 Col B. So if the text says "Dell computers" then Col B would say Dell.

Then in Worksheet1 Col C I want to display a dropdown list of all matching products belonging to the product category in Worksheet1 Col B (the result of the search) so that the correct product can be manually selected from the drop down. So if the text says "Dell laptop computers are great" then Col B would say Dell and the dropdown in Col C would show all the products for Dell (e.g. Desktop, Laptop, Tablet, etc.) and the user will select the correct product.

Which formulas should be used where e.g. search, index, Vlookup, etc.

I have attached a file set up with the columns described above.

Thanks in advance.
Question by:bobinorlando
    LVL 27

    Accepted Solution

    You can achieve this with:
    1) a formula to determine the key word (brand) in the phrase, and
    2) a named range that uses an OFFSET function to return the valid product types based on the brand found (if any)

    I've modified your workbook by removing the descriptor rows, so now, on Sheet1, the header row is
    A1: Text
    B1: Brand
    C1: Product

    I've then taken your two data lists on Sheet2 and assigned them to two Excel Tables:  "Brands" (col A) and "BrProducts" (col B:C).  This will be helpful in keeping your functions dynamic if you add/remove brands or products in the future.

    1) In cell B2, you insert the following array formula (entered with [Ctrl]+[Shift]+[Enter]) to display a valid brand name that may appear in the text in A2:

    2) Using the Name Manager, I created a named range called "PrLookup" that has the following formula in the "Refers to:" field:
    This determines the range on Sheet2 in the BrProducts table for any valid products for the displayed brand in column B
    Named Range used for data validationThen, in cell C2, I added a Data Validation rule that references PrLookup for the valid list of values and copied that cell down.
    data validation set up
    I also added some other test brands and text to test.  I initially questioned why - if the text statement may actually describe a product type - you would ask a user to select the product.  Then I realized that this may be a teaching exercise to instruct persons on interpreting sentence structure.  Is that correct?

    LVL 1

    Author Comment

    Thanks Glenn. Actually no, the instant file is merely a template. Other data will be substituted for the simple examples I provided and because the number of brands and products will be quite long - thousands of products of which 40-50 may roll up to a single brand -- and the text is much more complex that we are searching so we're going to manually match the names rather than trying to match them programmatically. Code works great when matching a brand name, but the text has many inconsistencies in the way product names are stated and will produce too many inaccurate matches so for that task a person is more accurate, thus the drop downs to at least narrow down what they have to review but enable them to easily pick off the right match and keep moving.
    LVL 27

    Expert Comment

    by:Glenn Ray
    Okay; interesting to hear more about how this will be applied.  Go ahead and experiment by expanding the existing tables and adding some sample text on the first sheet that more-closely resembles your actual data.  Let me know how it works.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
    How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now