+ Reply to Thread
Results 1 to 15 of 15

SUM Values based off Lookup Table

  1. #1
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    SUM Values based off Lookup Table

    I'd like to SUM all values in DATA TABLE col_b where DATA TABLE col_a has a value of MED in the LOOKUP TABLE.

    For example using the tables below..
    I want to sum col_b in the data table for all Cat# that have a lookup of HIGH. This would be Cat1, Cat2, and Cat5. Thus, equalling: 5+3+9+8 = 25

    Any ideas on how to get this to work?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thanks,
    JC
    Last edited by carlyman; 08-18-2011 at 09:10 AM. Reason: Showing that lookup table will be unordered

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based of Lookup Table

    If you list your Lookup_table with column a sorted alphabetically as per your sample, then....

    Assuming Lookup_table is in A1:B6, incl. headers and Data_table is in D1:E9, then try:

    =SUMPRODUCT(--(LOOKUP($D$2:$D$9,$A$2:$B$6)="High"),$E$2:$E$9)

    you can replace "High" with a cell reference.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based of Lookup Table

    Why does the list need to be ordered alphabetically? I tried it w/o arranging it that way and get #N/A, so it is obviously necessary.

    Unfortunately, the list must be sorted in a non-alpha and non-numeric order. So...any other potential way? I know I can always add a column to the data table and do a look up there, but really trying to avoid it.

    Thanks again,
    JC

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    LOOKUP() is one of the few functions that will allow you to build an array of text results within a formula so that you can compare and match to other tables... Lookup() unfortunately requires lookup data to be listed in sorted ascending order to work properly.

    I am trying to think of something else, but it is late in the day and my brainpower is going fast... I see other eyes on this thread and perhaps they will have something that will not require a helper column....

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    Okay give this a try.. with the same assumptions, except lookup table doesn't need to be in order....

    =SUMPRODUCT(--(ISNUMBER(MATCH($D$2:$D$9&"High",$A$2:$A$6&$B$2:$B$6,0))),$E$2:$E$9)

    again, you can replace "High" with a cell reference

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: SUM Values based off Lookup Table

    Hello carlyman,

    See the attached with DSUM formula.
    Attached Files Attached Files
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  7. #7
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based off Lookup Table

    @Haseeb: Thanks for the spreadsheet. It works, but I don't quite understand the limitations on what rows the information is on. If I cut and paste the lookup table down or insert a row at the top, the result is no longer valid.

    @NBVC: That works!!! In my actual task tho, I need to add one more filter (possibly two). There is another column in the data table that has a "type" field; using your example, make it column F. So, I attempted to just do the following:
    Please Login or Register  to view this content.

    I also tried multiplying instead of using a comma to separate the arrays, but that did not work either.

    Am I stretching the limit of Excel too much now? Very much appreciate your thoughts.

    Thanks again,
    JC

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    I would try:

    Please Login or Register  to view this content.
    for better robustness, perhaps add a special symbol between so that there is no accidental overlaps...

    e.g.

    Please Login or Register  to view this content.
    The underscore makes definitive separations in the words in case there may be an dubious overlap.

  9. #9
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based off Lookup Table

    NBVC,

    Thanks for the quick input....something is not quite adding up right in my actual task, so give me a bit to try and debug. At least I understand your recommended change

    -Jordan

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    I assumed the column F: Type is in the Lookup_Table....

    Also that you are looking for the word Type in column F in order for it to be a match....

  11. #11
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based off Lookup Table

    @NBVC: Sorry for my slow response, my work network seems to keep going down and can't access outside websites.

    But, I just read your last post and realized I probably wasn't clear. The "Type" is in the data table and has no correlation to the lookup table. It would be just a "normal" SUMPRODUCT array function.

    By normal, I mean (ignoring my lookup issue), the formula would be:
    =SUMPRODUCT((F2:F6)="TypeA")*E2:E6)

    My problem is I need to do the above filter together with the lookup function you provided. I can't quite figure out how to combine them.

    Thanks again for your help,
    JC

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    Can you repost a sample workbook with the added information and expected results?

  13. #13
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based off Lookup Table

    Attached is a sample file...hope it helps.

    -JC
    Attached Files Attached Files

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: SUM Values based off Lookup Table

    Try, in H11:

    =SUMPRODUCT(--(ISNUMBER(MATCH($A$12:$A$21&F11,$A$2:$A$6&$B$2:$B$6,0))),--($B$12:$B$21=G11),$C$12:$C$21)

    copied down

  15. #15
    Registered User
    Join Date
    04-20-2005
    Posts
    48

    Re: SUM Values based off Lookup Table

    Awesome...let me try this out in my actual work, but the question as asked is solved!

+ 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