Using IN operator to filter Airtable records by multiple values in a field

I’m working with an Airtable base that has a table called Items and I need to filter the records based on multiple values in a specific field.

Here’s my setup:

  • Table name: Items
  • Field name: Type
  • I have an array with values: ['electronics', 'books', 'games']

I want to retrieve all records where the Type field matches any of these values. I know I can filter by a single value, but I’m not sure how to use something like an IN operator to check against multiple values at once. Is there a way to do this efficiently in Airtable’s API or interface? I’ve tried a few approaches but haven’t found the right syntax yet.

You can handle this client-side too if the formula gets messy. Just grab all records first, then filter with your code.

I do this when filter conditions get complex and would make filterByFormula a nightmare:

const allowedTypes = ['electronics', 'books', 'games'];
const filteredRecords = allRecords.filter(record => 
  allowedTypes.includes(record.fields.Type)
);

Works great for under a few thousand records. The API call’s cleaner and you get way more flexibility. Easy to add conditions without building insane formula strings.

Only downside - you’re pulling extra data. If your table’s huge, stick with the filterByFormula approaches mentioned above.

totally! you can use the OR function in your filterByFormula. format it like this: OR({Type}='electronics', {Type}='books', {Type}='games'). it works perfect for api calls!

I like using FIND with concatenation instead. Try IF(FIND({Type}, 'electronics,books,games'), TRUE(), FALSE()) - it’s better at exact matches than SEARCH and you don’t need all those ORs. The trick is wrapping your values with delimiters like ',electronics,books,games,' and searching for ','&{Type}&',' so you don’t get partial matches. Works great with dynamic arrays too - just join the array values and drop them into the formula. I’ve been doing this for months with zero problems.

The OR approach works, but it gets messy with larger arrays. Building those OR formulas dynamically is a pain when you’ve got tons of values. I’ve had better luck with the SEARCH function: SEARCH({Type}, 'electronics,books,games'). Just treats your values like a comma-separated string and searches for matches. Watch out for partial matches though - if you’ve got ‘book’ and ‘books’ as separate types, this’ll catch both when you might only want one. Pass it as your filterByFormula parameter in the API. Works great when you’re building filters from arrays programmatically.

Another trick - use SWITCH for fixed values: SWITCH({Type}, 'electronics', TRUE(), 'books', TRUE(), 'games', TRUE(), FALSE()). It’s verbose but way faster than string searches on big tables, plus it handles exact matches perfectly.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.