+ Reply to Thread
Results 1 to 8 of 8

Lookup based on two criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2008
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Lookup based on two criteria

    Hi there

    I have a template P&L in which I have a hidden column with a unique code for each line item that appears. What I need to do is, pull the actual value for each unique line item from a separate Budget file, which is simple if you use indirect coupled with vlookup or sumif. However, I want all of the rows and columns from Jan10-Dec10 to act as a range.

    On the P&L template, in Column G9, I have the current month (Jan10). I want to be able to update this so that it’ll automatically pull through the corresponding unique figure based on the month I input into G9.

    I think an array formula might be necessary? Below is a copy of the budget file:

    Jan10 Feb-10 Mar10 Apr10
    Unique Identifier
    41AA121130100 10 11 15 18
    41AA121130150 10 11 15 18
    41AA121130605 10 11 15 18
    41AA121130700 10 11 15 18
    41AA121130810 10 11 15 18
    41AA121130820 10 11 15 18
    41AA121130821 10 11 15 18


    Would anyone please be able to help me? I'd really appreciate it.

    Cheers,
    Darren

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

    Re: Lookup based on two criteria

    Presumably given mention of INDIRECT & SUMIF the Budget file is open at all times ?
    (If not both of the above are precluded)

    You can use INDEX/MATCH or VLOOKUP, in both cases using a MATCH to determine appropriate column.

    Ignoring the external references for sake of simplicity - assume your table above is on a sheet called BUDGET in A1:M100 with months in B1:M1 and codes in A2:A100 - values in resulting matrix...

    =INDEX(BUDGET!$A$2:$M$100,MATCH($A10,BUDGET!$A$2:$A$100,0),MATCH($G$9,BUDGET!$B$1:$M$1,0))
    where A10 holds unique code of interest

    In VLOOKUP terms

    =VLOOKUP($A10,BUDGET!$A$2:$M$100,MATCH($G$9,BUDGET!$A$1:$M$1,0),0)

    I prefer INDEX/MATCH myself as it's more flexible (and can also result in fewer precedent cells / calculations).

  3. #3
    Registered User
    Join Date
    07-29-2008
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Lookup based on two criteria

    I've updated it to reflect my situation, but it's working perfectly. Thank you so very much.

    I was expecting to have the Budget file open, in order to propagate the updates, however using your Index/Match formula below, this is no longer necessary.

    I really appreciate your help. Thank you.

    Best wishes,
    Darren

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

    Re: Lookup based on two criteria

    Darren, I'm glad we resolve this for you but please be aware that should you opt to x-post (ie post the question in multiple online forums) we would ask you provide links accordingly:

    http://www.mrexcel.com/forum/showthread.php?t=448469

    reason being people may be wasting their time answering something that has (unbeknownst to them) been answered already

  5. #5
    Registered User
    Join Date
    07-29-2008
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Lookup based on two criteria

    Yes, of course! I apologise, my bad :-)

  6. #6
    Registered User
    Join Date
    07-29-2008
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Lookup based on two criteria

    Hi again,

    I have one last issue, which I was hoping you could please assist with before I am able to conclude my work on this spreadsheet.

    I need to add in an additional column which calculates the year to date. That is, for example, if I set the unique code to May-10, it'll give me the sum of Jan-May for each line item.

    Is there any way of doing this, other than by creating a dedicated YTD column in the Budget file, which I manually update to include the latest month?

    Thanks again.

    Cheers,
    Darren

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

    Re: Lookup based on two criteria

    Again, using the simplified internal version for sake of simplicity:

    =SUM(INDEX(BUDGET!$B$2:$B$100,MATCH($A10,BUDGET!$A$2:$A$100,0)):INDEX(BUDGET!$A$2:$M$100,MATCH($A10,BUDGET!$A$2:$A$100,0),MATCH($G$9,BUDGET!$B$1:$M$1,0)))

    it would of course make more sense to store the ROW match in an adjacent cell and calculate only once (refer to the calculated cell from within each INDEX)

  8. #8
    Registered User
    Join Date
    07-29-2008
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Lookup based on two criteria

    Very useful.

    Also, I've built the ROW match into a single cell as per your instruction.

    I appreciate your help on this. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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