+ Reply to Thread
Results 1 to 8 of 8

How to lookup two items and return the results attached to the those two values

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    How to lookup two items and return the results attached to the those two values

    Hello I am having trouble taking two values from a list of data and having them populate another list. It will probably be easier to understand with the example below.

    A1:Month B1:Customer C1: number of items D1:time
    A2: AUG B2:Customer 1 C2:5 D2:5:00
    A3: AUG B3:Customer 1 C3:6 D3:7:00
    A4: OCT B4:Customer 2 C4:7 D4:6:00

    This is a similar table to the data i want to use. I want to look up both the "Month" and "Customer" and return all the results for the customer that month. If I enter "AUG" into a cell and "Customer 1" into a cell it should return "2" results for "customer 1" from C2:D3( the number of items and time categories) I have tried using vlookup but it is only good for looking up the the top result of "Customer 1" rather than displaying both. I think some combination of index and match might work but I can't seem to find one that works how I'd like. Any help would be appreciated. I am new to this forum so I am not sure if I am posting this correctly.

  2. #2
    Forum Contributor
    Join Date
    05-24-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: How to lookup two items and return the results attached to the those two values

    Hi,

    with above table

    if you enter Aug in A7 & Customer1 in B7 , then put formula as per below

    C7 =COUNTIFS(A2:A4,A7,B2:B4,B7)

    D7 =SUMIFS(C2:C4,A2:A4,A7,B2:B4,B7)

    what calculation with time you want is not clear , i hope this is ok
    Click on * below if you find this helpful

    Thanks,
    A

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,050

    Re: How to lookup two items and return the results attached to the those two values

    Hi and welcome to the forum

    Assuming you gave your date selection in I1 and your customer selection in J1...
    =SUMIFS($C$2:$C$4,$A$2:$A$4,$I$1,$B$2:$B$4,$J$1)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    08-21-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How to lookup two items and return the results attached to the those two values

    Thank you for the replies, I was actually hoping to do something else with the data though. I want to have a user type in the Month and then type in the customer name and then the results to the right of the customer should display in a table below. For example if the customer typed in Aug and customer 1 then the table would return both the results for customer 1 (example below)

    Enter Month: AUG
    Enter Customer: Customer 1


    Number of items Time
    5 6:00
    6 7:00


    I used INDEX($C$2:$D$4, SMALL(IF($B$7=$B$2:$B$4,IF($B$8=$A$2:$A$4,ROW($B$2:$B$4)-ROW(INDEX($B$2:$B$4,1,1))+1)),ROW(B1)),COLUMN(B1))

    It works sometimes but when I try to reproduce it I get errors. I don't fully understand whats going on with the formula and just guessed on the row and column placements
    Thanks and sorry for the confusion in my original question

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to lookup two items and return the results attached to the those two values

    Try this...

    Data in the range A2:D4

    F2 = user entered/selected month
    G2 = user entered/selected customer

    Enter this array formula** in H2:

    =IFERROR(INDEX(C:C,SMALL(IF($A$2:$A$4=$F$2,IF($B$2:$B$4=$G$2,ROW(B$2:B$4))),ROWS(H$2:H2))),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy across to I2.

    Format I2 in whatever format 5:00 represents. Is that h:mm?

    Select H2:I2 and copy down until you get blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    08-21-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How to lookup two items and return the results attached to the those two values

    Quote Originally Posted by Tony Valko View Post
    Try this...

    Data in the range A2:D4

    F2 = user entered/selected month
    G2 = user entered/selected customer

    Enter this array formula** in H2:

    =IFERROR(INDEX(C:C,SMALL(IF($A$2:$A$4=$F$2,IF($B$2:$B$4=$G$2,ROW(B$2:B$4))),ROWS(H$2:H2))),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy across to I2.

    Format I2 in whatever format 5:00 represents. Is that h:mm?

    Select H2:I2 and copy down until you get blanks.
    Thanks a lot! That's exactly what I needed and it is a much simplier formula than the one I was trying to work with. I was able to document my entire list no problems. Oh and for the confusion with time, I was just simply reporting the time an order was processed and yes it is in h:mm format. Thanks again.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to lookup two items and return the results attached to the those two values

    You're welcome. Thanks for the feedback!

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to lookup two items and return the results attached to the those two values

    This is more or less a re-hash of the earlier responses in the form of a workbook. I didn't know what you wanted with the time column so I figured that I would give you the Average of the times.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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] Is it possible to lookup multiple values and return multiple rows of results?
    By justin11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-20-2013, 12:02 PM
  2. Replies: 2
    Last Post: 11-03-2012, 02:53 PM
  3. Formula to return the values in the attached sheet
    By charanam in forum Excel General
    Replies: 3
    Last Post: 08-26-2011, 09:50 AM
  4. [SOLVED] lookup multiple values of a single cell and return sum of results
    By Zeppelin17 in forum Excel General
    Replies: 7
    Last Post: 08-10-2011, 07:09 PM
  5. lookup 2 values and return multiple results
    By humboldtguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2010, 09:49 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