I have an Airtable field titled: Course Status and to the right of that field is Total Enrollment. In my Excel spreadsheet version, I used a vlookup to return the value of ‘course status’
The formula: =VLOOKUP(K@Enrolled],Table30,2,FALSE)
Table30
0-2 enrolled = On Standby
3-9 enrolled = Low Enrollment
10-28 = Will Make!
Is there a way to accomplish this in Airtable?
Thanks in advance for your support!
Lisa
Page 1 / 2
Have you tried using a lookup field? It should work perfectly for what you want to do.
Have you tried using a lookup field? It should work perfectly for what you want to do.
I also have this problem and it’s not at all clear how to use Lookup to accomplish this.
I also have this problem and it’s not at all clear how to use Lookup to accomplish this.
This was something that I was looking for as well as I needed to do quite a bit of matching between my tables - that were previously using VLOOKUP in Excel. This did not seem to be possible with regular Airtable functions (and I tried a lot of crazy stuff), so I started looking into the Scripting block.
This actually allowed me to make a perfect solution. OK, almost perfect, you still need to change the name of tables and columns manually in the code, but with comments below this should be fairly straight forward.
I have also made a quick video about it:
I hope that helps!
Hi,
This was something that I was looking for as well as I needed to do quite a bit of matching between my tables - that were previously using VLOOKUP in Excel. This did not seem to be possible with regular Airtable functions (and I tried a lot of crazy stuff), so I started looking into the Scripting block.
This actually allowed me to make a perfect solution. OK, almost perfect, you still need to change the name of tables and columns manually in the code, but with comments below this should be fairly straight forward.
I have also made a quick video about it:
I hope that helps!
Continuing the discussion from Vlookup for Airtable?: - This is awesome - exactly what I was looking for. One thing though:
How I can look up if the lookupValue is in a lookup field? (or a formula field that links to another field).
It seems like the cell has no value and therefore the whole lookup runs into nothing.
A way by e.g. extending the code above so that it might solve this, also?
Solution to this is highly appreciated -
Thank you
Hi,
This was something that I was looking for as well as I needed to do quite a bit of matching between my tables - that were previously using VLOOKUP in Excel. This did not seem to be possible with regular Airtable functions (and I tried a lot of crazy stuff), so I started looking into the Scripting block.
This actually allowed me to make a perfect solution. OK, almost perfect, you still need to change the name of tables and columns manually in the code, but with comments below this should be fairly straight forward.
I have also made a quick video about it:
I hope that helps!
Another question: how could you define a fallback value (could be a static one “not matched!”) in case that there was no match with the values in the lookup table?
Continuing the discussion from Vlookup for Airtable?: - This is awesome - exactly what I was looking for. One thing though:
How I can look up if the lookupValue is in a lookup field? (or a formula field that links to another field).
It seems like the cell has no value and therefore the whole lookup runs into nothing.
A way by e.g. extending the code above so that it might solve this, also?
Solution to this is highly appreciated -
Thank you
I think both cases can be solved with help of "if"conditions. First one checking if the original column/field is empty (in case you have many empty values there). Second case already has a condition that executed when value is found, so it needs to be completed with else statement to execute action if case of not matching values.
Something like this:
Here is a link to a sample base with examples:
It should be possible to see the code of blocks once you copy the base (let me know otherwise).
Here is also description of the process on Medium (non-paywalled link)
I think both cases can be solved with help of "if"conditions. First one checking if the original column/field is empty (in case you have many empty values there). Second case already has a condition that executed when value is found, so it needs to be completed with else statement to execute action if case of not matching values.
Something like this:
Hi, - this is great & solves the setting of the “else” value!
The first check if not empty => basically does only what is says (gatekeeper for valid values) - but it does not solve the target:
Hmmm, I thought that was the entire point of this script example - to use each value in the primary table to lookup a record that matches in the secondary table and update a column back in the primary table.
This is precisely the pattern I use to do this and often. Pretty sure it’s doing that. If it wasn’t, how would explain these leading-zero values and one “Nothing Found” in the primary table?
Here is a link to a sample base with examples:
It should be possible to see the code of blocks once you copy the base (let me know otherwise).
Here is also description of the process on Medium (non-paywalled link)
Thanks, I found the script in your Medium article too. How can I feed data about which tables to look in and which fields to search from a record’s properties?
I am setting up a base called “Search” that has the following properties:
Name of base to search
Output column to generate the match list (record IDs)
Column to search
Query text
Exact match or contains
Parent filter
A parent filter is one that dictates which records a child filter can use, so it could speed up the child’s search by already having eliminated some possibilities.
I would like the table to calculate all the records that match the search-filter query as a list of record IDs. The result would look like this: rec6a2kirXC7AESjq ;; recYo9A3ylGxI8w0A ;; recr59z46kzIoZMFT for three matches or much longer when there are many matches.
Thanks, I found the script in your Medium article too. How can I feed data about which tables to look in and which fields to search from a record’s properties?
I am setting up a base called “Search” that has the following properties:
Name of base to search
Output column to generate the match list (record IDs)
Column to search
Query text
Exact match or contains
Parent filter
A parent filter is one that dictates which records a child filter can use, so it could speed up the child’s search by already having eliminated some possibilities.
I would like the table to calculate all the records that match the search-filter query as a list of record IDs. The result would look like this: rec6a2kirXC7AESjq ;; recYo9A3ylGxI8w0A ;; recr59z46kzIoZMFT for three matches or much longer when there are many matches.
I think it is defined at lines 3. 7, 12, and 17.
I think it is defined at lines 3. 7, 12, and 17.
The problem is that I would need to write the column names into the code. I want the code to repeat for every record in a table when I call the VLookup function. Each record where it runs would have a property for each of the inputs and outputs. Does that make sense?
I think it is defined at lines 3. 7, 12, and 17.
I basically need a Vlookup where I define the columns and cells within the formula, just like Excel. Is that possible to do with the Scripting block?
The problem is that I would need to write the column names into the code. I want the code to repeat for every record in a table when I call the VLookup function. Each record where it runs would have a property for each of the inputs and outputs. Does that make sense?
Yes, it does, but I think we need to establish a few things first:
I responded to a specific question about the points in someone else’s code where the table and field names were specified.
I did so only to accelerate your changes to that code.
The strategy is now on a new compass heading; one that I’m not entirely understanding mostly because I’m working without any indication of a specific objective in the context of a specific table and data.
Pretty much all aspects of lookup automation are possible with Script Blocks; it’s a simple matter of code. But, it’s very difficult to recommend a specific approach with so few details and especially so as an addendum to a thread that began in 2017.
I recommend you head on over tho the Script Block part of the community and present your requirements for your specific objective. I would leave out “VLookup”, and mentions of “just like Excel” because these are biased suppositions of an implementation approach and may work against you. Airtable is not Excel nor is it a “spreadsheet”.
Ideally, a requirements objective is void of implementation details or suggestions of a particular approach and will make it far easier for other community experts to better understand the business goal. Implementation ideas will probably then be in abundance.
Great script @Greg_F! Thanks for helping and contributing.
Is there a way to let this script run automatically, so I don’t have to trigger it manually each time when a new record is added?
Great script @Greg_F! Thanks for helping and contributing.
Is there a way to let this script run automatically, so I don’t have to trigger it manually each time when a new record is added?
Hi,
You could use the new Automation feature to run a script when a record is added.
Note 1 - The scripts in Automation are limited by run time (30 sec) and CPU use (1 sec? I believe) so more complex scripts will not work.
Note 2 - Since you are talking about adding a new record, this could be actually a much simpler script, just searching for a value from the new record in the target table to match. This could work depending on size of the database. It might be also possible to use Automation action Update instead of script, but I would have to check this one.
Hi,
This was something that I was looking for as well as I needed to do quite a bit of matching between my tables - that were previously using VLOOKUP in Excel. This did not seem to be possible with regular Airtable functions (and I tried a lot of crazy stuff), so I started looking into the Scripting block.
This actually allowed me to make a perfect solution. OK, almost perfect, you still need to change the name of tables and columns manually in the code, but with comments below this should be fairly straight forward.
I have also made a quick video about it:
I hope that helps!
Thanks, this is great! I think you need to add await to the
await mainTable.updateRecordAsync(record, {
line, I was having trouble in a slightly larger table of it just updating some records.
Thanks, this is great! I think you need to add await to the
await mainTable.updateRecordAsync(record, {
line, I was having trouble in a slightly larger table of it just updating some records.
Yes! Thank you for noticing that! I have corrected the gist.
Hi,
This was something that I was looking for as well as I needed to do quite a bit of matching between my tables - that were previously using VLOOKUP in Excel. This did not seem to be possible with regular Airtable functions (and I tried a lot of crazy stuff), so I started looking into the Scripting block.
This actually allowed me to make a perfect solution. OK, almost perfect, you still need to change the name of tables and columns manually in the code, but with comments below this should be fairly straight forward.
I have also made a quick video about it:
I hope that helps!
@Greg_F This code is tremendously helpful. In your example if the value of item.barcode is removed the link in the Product field remains? In my instance I want that link to be severed. Do you know how I could do that?
@Greg_F This code is tremendously helpful. In your example if the value of item.barcode is removed the link in the Product field remains? In my instance I want that link to be severed. Do you know how I could do that?
@Laura_Greer you right, the link would remain if the value in the lookup table gets deleted (unless the record in the lookup table gets deleted as well). In this case, you would have to run the script again, with an explicit declaration that if there is no match - the link field should be updated to empty.
@Laura_Greer you right, the link would remain if the value in the lookup table gets deleted (unless the record in the lookup table gets deleted as well). In this case, you would have to run the script again, with an explicit declaration that if there is no match - the link field should be updated to empty.
Yeah, I can’t figure out how to do that. I’m not. I’m a complete novice. Can you give me a push in the right direction?