Thursday, December 29, 2011

An update to vlookup and arrayformula

For those trying to use arrayformula in Google Spreadsheets, I thought I would give a few examples that might help when designing your function.  In addition, I've provided a general example where you can fill in your corresponding ranges to build the function.  Let me know if you have any problems!


To customize use this key.
=arrayformula(if(row([range1])=1,"Impossible",vlookup([range1],[range2],{N}*sign(row([range1])),FALSE)))

where
[range1]: range of values to be looked up
[range2]: table of data where look up values are in column 2
N: number of column that has the data you want to return


I've also embedded a spreadsheet here that shows a few examples of how to use this:


Also, if you want to play with this spreadsheet feel free to make your own copy here:
Using arrayformula with vlookup template

Cheers!

13 comments:

  1. What the... why does this work?

    ReplyDelete
  2. Oh, and thank you very much for saving me a lot of frustration!

    ReplyDelete
  3. How should it be modified in order to update automatically in columns?

    ReplyDelete
  4. If you put that formula above in row 2 of the column that you want to display values, and update the bolded values with your ranges, it should update dynamically. If you are having problems, feel free to write back here with a link to your example.

    ReplyDelete
    Replies
    1. UPDATE: I am facing a similar challenge now, where I need to show inside a cell all of the filtered rows from another spreadsheet matching a key value. But somehow I can't get it to work inside an array formula to update by itself for every row. It produces an error that says "ranges length do not match" (translation by me from Greek)

      Delete
    2. Can you post a link to your spreadsheet and I can take a look?

      Delete
    3. You can find a simple one I made, here: https://docs.google.com/spreadsheet/ccc?key=0Auf1OZbEi1vPdG1kZjJKTEIycTA4bmI2aVVnTzhEZkE

      Delete
  5. What do you want to appear in that column? The Part No. associated with each ID?

    Can you also allow anyone to edit the spreadsheet?

    ReplyDelete
    Replies
    1. Opened for edits the spreadsheet. Yes, I'd like associated Part Nos to appear in the column but all of them in the same row.

      Delete
  6. I see what you are trying to do now. That is a little more complicated and I'll need some time to sort that out. For now, I'm able to grab the first part number that comes in the list based on your ID but not all of the different part numbers. We will need to employ filter() and/or query().

    ReplyDelete
  7. Thanks a lot for your help. It's really crucial to me that I solve this puzzle because I will have the same task in other columns/spreadsheets as well. I have thought of query too, but the documentation says it doesn't support dynamic ranges and I had given up on the idea. I'll be waiting for your help, thanks a lot in advance!

    ReplyDelete
  8. Check out your spreadsheet. Top Contributor Adam has a solution for you! I hope that is what you are looking for.

    ReplyDelete
  9. Had to revert to a previous version cause someone had deleted his contribution. it seems to be working fine, thank you both!

    ReplyDelete