+ Reply to Thread
Results 1 to 7 of 7

Indexing Multiple Tables

  1. #1
    Registered User
    Join Date
    08-11-2010
    Location
    Seattle
    MS-Off Ver
    Excel 2003
    Posts
    4

    Indexing Multiple Tables

    I've been doing quite a bit more in Excel lately and have even taken a class or two that was supposed to be "Advanced". Most everything I've learned in these classes are things I've already self taught, and for my latest endeavor, very little help.

    I've simplified my example for security and brevity. Actual worksheet is 38 columns by 7000+ rows.

    Here's the situation:

    Current customer product inventories for monthly recurring services are listed in the A4:C58 table. What I am trying to accomplish is to write a formula with parameters of Product, State, and Term/Qty based on the product pricing tables to automate the process of pricing out the new promo price for column D. Also, since there are products that are not eligible for promotion, have those return the current price listed.

    I've been trying to use INDEX in an IF or VLOOKUP but can't quite map it out to work.

    Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Indexing Multiple Tables

    Perhaps something like this.

    The colored sections are NAMED RANGES I've created to make the formula simpler to construct. K5:R18 is named ProductA, etc.

    The a named range for States and another for Periods along the left and top of one of the the first table.

    The formula D5 is a standard INDEX/MATCH, but the INDEX() portion uses INDIRECT to index the correct named range based on the value in column A.

    =INDEX(INDIRECT("Product" & A5), MATCH($B5, States, 0), MATCH($G$2, Periods, 0))

    Copied down, that formula finds the correct cell in the indexed range and returns the value. The #REF answers are for the tables yet to be created and named.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-11-2010
    Location
    Seattle
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Indexing Multiple Tables

    That's awesome. Thanks for the help. One issue on the #REF values is that there are thousands of products that I don't have a database to pull the prices from. So for these products I would need to refer back to the original price. Any thoughts?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Indexing Multiple Tables

    Try this in D5, then copy down:

    =IF(ISERROR(INDEX(INDIRECT("Product" & A5), 1, 1)), C5, INDEX(INDIRECT("Product" & A5), MATCH($B5, States, 0), MATCH($G$2, Periods, 0)))

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Indexing Multiple Tables

    Given the return is a number you can use:

    Please Login or Register  to view this content.
    Given the tables are to all intents and purposes identical there's no real need for Volatile INDIRECT (and/or Named Ranges) as I see it.

    Simply reference all tables in the INDEX range and adjust the row_index accordingly (ie Match Product and offset by Match of State), ie:

    Please Login or Register  to view this content.
    Above assumes Product Name and States are never the same (ie no Product AZ)

  6. #6
    Registered User
    Join Date
    08-11-2010
    Location
    Seattle
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Indexing Multiple Tables

    Quote Originally Posted by DonkeyOte View Post
    Given the return is a number you can use:

    Please Login or Register  to view this content.
    Given the tables are to all intents and purposes identical there's no real need for Volatile INDIRECT (and/or Named Ranges) as I see it.

    Simply reference all tables in the INDEX range and adjust the row_index accordingly (ie Match Product and offset by Match of State), ie:

    Please Login or Register  to view this content.
    Above assumes Product Name and States are never the same (ie no Product AZ)

    Wow, that works out great. I was able to put that in fairly easily. I did run into one issue that there is the possibility that when dealing with the products, there are instances where one item can have two product names. This happens when a product is an addition to an existing product whereby both are listed but only one carries the dollar value and the new formula would return a new value for both products thereby double billing.

    I solved that by adding an =IF(C5=0,0,[remaining formula] so it would precede and always give a zero dollar amount for products that start at zero.

    For my learning, I can work backwards through the INDEX and beyond, but I can't seem to track the =LOOKUP(9.99E+307,CHOOSE({1,2},C5, part of the string.

    Anything that would help me better understand this part would be appreciated.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Indexing Multiple Tables

    From a prior post:

    Quote Originally Posted by D.O
    LOOKUP assumes all values in the lookup_vector are sorted in ascending order (irrespective of reality)

    LOOKUP returns last value <= criteria in the lookup_vector (or associated value from result_vector if specified)

    LOOKUP ignores all values in the lookup_vector that are not of the same data type as the criteria - this (importantly) includes error values
    ie error values in the lookup_vector won't cause the LOOKUP to fail.
    So in this context:

    i) the criteria is a VERY big number

    ii) the lookup_vector itself consists of two values c/o of CHOOSE: the original price and the result of the INDEX

    ii) the lookup_vector items are ordered in terms of least preference (this is important)
    It follows then that the LOOKUP will return the last number found in the lookup_vector which will either be the promotion price (Index succeeds) or where no such price exists (Index error) the original price.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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