+ Reply to Thread
Results 1 to 15 of 15

Vlookup or other formula to return data given criteria

  1. #1
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Vlookup or other formula to return data given criteria

    Hi all,

    I was wondering if any one can provide any advise on a formula to find value 'X' (table to the bottom) from the data table (table on top), I have used Vlookup but unfortunately it only allows you to search from 1 criteria. As you can see below in order for X to be correct, the criteria needs to include Start/End/Date then should this match in the data table(top), the value next to start/end/date (table to the top) should be returned. In the case of 01/02/2011, 00:30:00 01:00:00 - x should be 15.

    start End Date No
    00:30:00 01:00:00 01/02/2011 15
    01:30:00 02:00:00 01/02/2011 14
    04:00:00 04:30:00 01/02/2011 15
    05:00:00 05:30:00 01/02/2011 1
    06:00:00 06:30:00 01/02/2011 8
    06:30:00 07:00:00 01/02/2011 5
    00:30:00 01:00:00 02/02/2011 5
    01:30:00 02:00:00 02/02/2011 5
    04:00:00 04:30:00 02/02/2011 4
    05:00:00 05:30:00 02/02/2011 78
    06:00:00 06:30:00 02/02/2011 112
    06:30:00 07:00:00 02/02/2011 15

    01/02/2011 02/02/2011
    00:30:00 01:00:00 x x
    01:30:00 02:00:00 x x
    04:00:00 04:30:00 x x
    05:00:00 05:30:00 x x
    06:00:00 06:30:00 x x
    06:30:00 07:00:00 x x



    Any advice is greatly appreciated
    Last edited by haduken; 02-12-2011 at 02:03 PM. Reason: clarity

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Vlookup or other formula to return data given criteria

    One way to do this is to create a 'helper' column in both of your tables which contains the two dates concatenated together. This effectively merges them into a single value and you can then use this in the VLOOKUP formula.
    Martin

  3. #3
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Quote Originally Posted by mrice View Post
    One way to do this is to create a 'helper' column in both of your tables which contains the two dates concatenated together. This effectively merges them into a single value and you can then use this in the VLOOKUP formula.
    can you explain this further please? do I create the helper column in th data table (the table it searches in inorder to retrieve value X) or in both, as you can see there is start time, end time and date in which the criteria must match?

  4. #4
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    Hi - maybe if you were to upload your spreadsheet it may help. Also, in the sheet describe your desired output
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  5. #5
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Quote Originally Posted by Blake 7 View Post
    Hi - maybe if you were to upload your spreadsheet it may help. Also, in the sheet describe your desired output
    Please find attached, its a tricky one re attached: call.xls
    Last edited by haduken; 02-12-2011 at 05:19 PM. Reason: update

  6. #6
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    ok - thanks for the upload, saves me typing out the table. Just to be sure ive got it - G2 and 3 should be 15 and 14 and cells h2 and 3 should both be 5........ correct?

  7. #7
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Quote Originally Posted by Blake 7 View Post
    ok - thanks for the upload, saves me typing out the table. Just to be sure ive got it - G2 and 3 should be 15 and 14 and cells h2 and 3 should both be 5........ correct?
    Thats correct

  8. #8
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    Hiya - am working on it......... may have to get back to you tomorrow

  9. #9
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Quote Originally Posted by Blake 7 View Post
    Hiya - am working on it......... may have to get back to you tomorrow
    No worries, have a good one.

  10. #10
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    EDIT: ive uploaded the spreadsheet for you.

    Hi Had - sorry about the delay - nearly there........ ok, as per your spreadsheet

    H2 use CSE to enter then copy down
    =INDEX($D$2:$D$13,MATCH(1,($A$2:$A$13=F2)*($B$2:$B$13=G2)*($C$2:$C$13=$H$1),0))

    and in I2 again use CSE to enter then copy down
    =INDEX($D$2:$D$13,MATCH(1,($A$2:$A$13=F2)*($B$2:$B$13=G2)*($C$2:$C$13=$I$1),0))

    Hope this helps you out..
    Attached Files Attached Files
    Last edited by Blake 7; 02-12-2011 at 06:59 PM.

  11. #11
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Quote Originally Posted by haduken View Post
    No worries, have a good one.
    Hi there,

    Many thanks for the update,

    The formula does not appear to work given a change in the data table if we add more data to it, i.e I have added in date 03/02/2011 and their respective values and there is an error?

    please see attached and changes since the previous...

    many thanks
    Hadu.xls

  12. #12
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    [QUOTE=haduken;2470966]Hi there,

    Many thanks for the update,

    The formula is working perfectly, can you explain the stages of the formula

    =INDEX($D$2:$D$19,MATCH(1,($A$2:$A$19=F2)*($B$2:$B$19=G2)*($C$2:$C$19=$J$1),0))

    it would be good for me to learn, such as match(1, ****) should'nt the "1" in that part of the formula be the lookup value? and how does the multiplication (*) function work in this instance, I have noticed ($A$2:$A$19=F2)*($B$2:$B$19=G2)*($C$2:$C$19=$J$1)

    please let me know

  13. #13
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    Hi glad to hear it's working fine.

    btw - the solution I offered is one way of doing it (it works)! however, there are probably more efficient ways out there to be explored........

    re your questions, please find a link below which will tell you all you need to know circa Index Match.

    http://www.contextures.com/xlfunctions03.html

    Please mark your thread as solved.

    Cheers

  14. #14
    Registered User
    Join Date
    02-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Vlookup or other formula to return data given criteria

    Thanks,

    The only issue with this is I have to select specific cells on the data table in order for it to return the values. Can you advise whether it is possible to select lookup for the whole of column A lets say instead of A2:A19, I have entered: D:D instead but theres a #Num error when I try and replace it?

    please advise

  15. #15
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Vlookup or other formula to return data given criteria

    The only issue with this is I have to select specific cells on the data table in order for it to return the values
    I'm not sure what you mean.......

    Can you advise whether it is possible to select lookup for the whole of column A lets say instead of A2:A19
    Yes, here's the code

    =INDEX($D:D,MATCH(1,(A:A=F2)*(B:B=G2)*(C:C=$H$1),0))

    I have entered: D:D instead but theres a #Num error when I try and replace it?
    In an array formula all lookup arrays need to be the same length.

    If this clears everything up please mark as 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