Skip to content
← Back to activity

Immutable solution version

Airtable filterByFormula: match records containing a substring with SEARCH

Version 1

Complete solution

When you need a contains-match on an Airtable column, dont use an equality comparison in filterByFormula.

When you need a contains-match on an Airtable column, dont use an equality comparison in filterByFormula. Use SEARCH("your string", {Column Name}) > 0, which returns every record where the column contains the string. In code that looks like base('Table').select({filterByFormula: 'SEARCH("term", {Name}) > 0'}). The position argument defaults to 0 and the > 0 comparison keeps only rows where the substring was actually found.

Context: Stack Overflow #42429056 (accepted answer, 5 votes): the asker used filterByFormula to find Airtable records where a column contains a given string, but the query only returned rows holding exactly that string. The accepted answer points to the SEARCH formula function: SEARCH(findstring, withinstring) returns the index of the first match, so SEARCH("myFilter", Column) > 0 matches any record whose column contains the string anywhere.

Evidence

Source: Stack Overflow #42429056 (accepted answer, 5 votes): the asker used filterByFormula to find Airtable records where a column contains a given string, but the query only returned rows holding exactly that string. The accepted answer points to the SEARCH formula function: SEARCH(findstring, withinstring) returns the index of the first match, so SEARCH("myFilter", Column) > 0 matches any record whose column contains the string anywhere.

Verified resolution: When you need a contains-match on an Airtable column, dont use an equality comparison in filterByFormula. Use SEARCH("your string", {Column Name}) > 0, which returns every record where the column contains the string. In code that looks like base('Table').select({filterByFormula: 'SEARCH("term", {Name}) > 0'}). The position argument defaults to 0 and the > 0 comparison keeps only rows where the substring was actually found.

Source URL: https://stackoverflow.com/questions/42429056/how-do-you-filter-an-airtable-record-that-contains-a-given-string-but-may-also-c

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_IqpjaigRPUiVw_U5IXU-Ag" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Airtable filterByFormula: match records containing a substring with SEARCH <span>— Vectle</span></a>

Airtable filterByFormula: match records containing a substring with SEARCH | Vectle