+ Reply to Thread
Results 1 to 17 of 17

How Can I Do a Double Lookup?

Hybrid View

Rod Stewart How Can I Do a Double Lookup? 06-22-2012, 06:44 PM
tigeravatar Re: How Can I Do a Double... 06-22-2012, 06:55 PM
Rod Stewart Re: How Can I Do a Double... 06-22-2012, 07:41 PM
Cutter Re: How Can I Do a Double... 06-22-2012, 07:59 PM
Cutter Re: How Can I Do a Double... 06-22-2012, 08:11 PM
Rod Stewart Re: How Can I Do a Double... 06-22-2012, 09:42 PM
Pcguy1 Re: How Can I Do a Double... 06-23-2012, 01:58 AM
Cutter Re: How Can I Do a Double... 06-23-2012, 06:28 AM
Rod Stewart Re: How Can I Do a Double... 06-23-2012, 11:44 AM
Cutter Re: How Can I Do a Double... 06-23-2012, 12:09 PM
Cutter Re: How Can I Do a Double... 06-23-2012, 12:57 PM
Rod Stewart Re: How Can I Do a Double... 06-23-2012, 01:17 PM
Cutter Re: How Can I Do a Double... 06-23-2012, 01:41 PM
Rod Stewart Re: How Can I Do a Double... 06-23-2012, 03:08 PM
Rod Stewart Re: How Can I Do a Double... 06-23-2012, 03:10 PM
Cutter Re: How Can I Do a Double... 06-23-2012, 03:22 PM
Rod Stewart Re: How Can I Do a Double... 06-23-2012, 04:25 PM
  1. #1
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Red face How Can I Do a Double Lookup?

    Hi All;
    New to this forum.
    I apologize if this topic has been recently discussed, but here it is:

    Suppose I have a table of data, several columns and several rows.
    Is there a way I can do a vertical lookup based on one value, then from that row of data do a horizontal lookup based on another value, and return a single value?
    In other words is there a way I can embed both lookup functions in one cell?

    Thanks for any help,
    Rod

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How Can I Do a Double Lookup?

    Rod,

    Welcome to the forum!
    What you're looking for is Index() and Match().

    Based on your description, the formula will look something like this:
    =INDEX(TableOfValues,MATCH(RowMatchValue,RowHeadersColumn,0),MATCH(ColumnMatchValue,ColumnHeadersRow,0))

    If you get stuck, post back with an example workbook. Good luck
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    OK thanks for that information.
    Here is the sheet I am working on:

    Vessel Outside Diameter, Inches 132 Length. S/S 60 Ft.
    Vessel Design Pressure; psig 261 Height of H2O 14 Ft.
    Vessel Max Design Temp; °F 450 Material: SA-516-70
    Allow. Stress Value of material; psi 20000 L/D Ratio: 5.45 to one
    Joint Efficiency 1.00
    Corrosion Alllowance, Inches 0.1250 Material Density Lbs/ft3 490

    Design Temp; F, up to
    Material 300 400 500 600 700 800 900 1000
    SA-516-70 20,000 20,000 20,000 19,400 18,100 12,000 6,700 2,500
    SA-516-60 17,100 17,100 17,100 16,400 15,300 10,800 5,900 2,500
    SA-515-60 17,100 17,100 17,100 16,400 15,300 10,800 5,900 2,500
    SA-285-C 15,700 15,700 15,700 15,300 14,300 10,800 5,900 NA

    This finds the allowable stress for an ASME pressure vessel based on material grade and design temperature.
    The idea is to use the material grade (eg SA-516-70), and the design temp (450 F in this case) to return the allowable stress from the table (should be 20,000 in this case). This value is then used in the rest of the spreadsheet to calculate head and shell minimum required thicknesses.

    If I can get some guidance as to how to set this up, I would be very appreciative!

    Rod
    Last edited by Rod Stewart; 06-22-2012 at 07:46 PM.

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    Here is a simple sheet with the method you need:
    Attached Files Attached Files

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    Just thinking more about this - do you need to choose the lowest temp value that exceeds your design temp value? For your example would you be looking under the 500 column or the 400 column?
    The formula I gave you finds the 400 column - so if you need the 500 column replace the formula in cell I2 with this:

    =INDEX(B6:I9,MATCH(C2,A6:A9,0),IF(ISNA(MATCH(F2,B5:I5,0)),MIN(COUNT(B5:I5),MATCH(F2,B5:I5,1)+1),MATCH(F2,B5:I5,0)))

    It will return from the column of an exact temp match - otherwise from 1 column to right (last column being the max)

  6. #6
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    Cutter;
    Thanks very much; that works quite well when I copied in your second revised formula.
    You interpretted it correctly; when the temperature is between column values it should select the stress corresponding to the next higher column temp value.
    The only issue now is that when the design temp is set to an exact column value (eg; 600) it returns ######. One digit less or more works well however.
    How can we get it to return the correct value when the temp is an exact column value?

    Thanks again,
    Rod

  7. #7
    Registered User
    Join Date
    06-23-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: How Can I Do a Double Lookup?

    HI,

    One option is to use "IF". The formula is a bit too long.

    =IF(ISERROR(MATCH(F2,B5:I5,0))=TRUE,VLOOKUP(C2,A6:I9,MATCH(HLOOKUP(F2,B5:I5,1,TRUE),B5:I5)+2,FALSE),VLOOKUP(C2,A6:I9,MATCH(HLOOKUP(F2,B5:I5,1,TRUE),B5:I5)+1,FALSE))

    You can use the same to the current formula.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    @ Rod

    I'm not getting that result when I set the temp to 600 or any other exact temp. It is returning the correct value for me.
    Copy the formula you're using and paste it here.

    One question I still have, though. I placed a condition in the formula to get a value from the last column even if the design temp exceeds 1000. Should it return a warning instead? Like "Design temperature exceeds limit".

  9. #9
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    Cutter;
    When I first copied your formula there is an errant space in the last MATCH function, which rendered it inoperable I guess.
    When I corrected that it works just fine!! Thank you very much for the help.

    The stress value selected should be up to and including the temp given in the column. ie 550F should return the value for 600 F and so on.
    If the design temp is 601, then it should return the value for the next column temp, ie 700F.
    So it is working great as you presented it.
    Wish I was smart enough to figure that out.

    As great as Excel is, I am surprised that there is not an all in one function to accomplish this task.
    I have several engineering spreadsheets that can benefit from this functionality, and now that you have shown me the way, I will incorporate this into each, as I get time. I have Larsen's book "Engineering With Excel"; and surprisingly, there is nothing like this in it.
    This truly is a great site for Excel users.

    Thanks and best regards,
    Rod

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    You're very welcome. Glad I was able to help.

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    @ Rod
    Was doing a bit more testing on the formula I gave you and discovered a flaw. It fails when a temp of less than 300 (the minimum in the table) is entered.

    Try this as a fix:

    =INDEX(B6:I9,MATCH(C2,A6:A9,0),IF(COUNTIF(B5:I5,F2),MATCH(F2,B5:I5,0),IF(F2<B5,1,MIN(MATCH(F2,B5:I5,1)+1,COUNT(B5:I5)))))

    sorry about that

    revised example attached:
    Attached Files Attached Files
    Last edited by Cutter; 06-23-2012 at 01:12 PM.

  12. #12
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    Cutter;
    I see what you mean.
    I added a new column to the left of the 300F column, with a value of -20F. This represents the stresses at the minimum temp for these materials; ie -20F.
    I then expanded the references in the formula to cover the new table size, and it works just fine. Thanks for pointing that out.
    If I knew how to attach a file I would do that.

    Rod

  13. #13
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    Instructions for attaching can be found by clicking Forum Rules @ top of page - scroll down to below rule #13

  14. #14
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    OK I am going to try attaching the file.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    Wow, looks like it worked!

  16. #16
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Can I Do a Double Lookup?

    Yep, that solves it, too.
    You could put Data Validation on cell F2 to warn when too high a number is typed - that would eliminate need for that circumstance in the formula.

  17. #17
    Registered User
    Join Date
    06-22-2012
    Location
    Calgary, AB
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How Can I Do a Double Lookup?

    Cutter;
    Another good idea.
    I'll probably give that a try as well.

    Thanks,
    Rod

+ 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