Skip to main content
Solved

Formula match element in list of postal codes (OR)

  • March 23, 2021
  • 5 replies
  • 28 views

Forum|alt.badge.img+3

How can I write a formula where I could say "return true if value is 95000, or starts with 923, or …)

I’d probably use a regex for this but airtable doesn’t allow that. What’s the next best thing?

Best answer by augmented

There are limits to what you can do, but it should get you started.

5 replies

Forum|alt.badge.img+18
  • Inspiring
  • Answer
  • March 23, 2021

There are limits to what you can do, but it should get you started.


Grunty
Forum|alt.badge.img+15
  • Inspiring
  • March 23, 2021

Would something like this work for you?:
IF(OR(Value=95000, AND(Value>=92300, Value<=92399), etc..), true, false)


Forum|alt.badge.img+3
  • Author
  • Inspiring
  • March 23, 2021

There are limits to what you can do, but it should get you started.


I thought regexes weren’t possible with Airtable :open_mouth: Thanks for pointing this out!


Forum|alt.badge.img+3
  • Author
  • Inspiring
  • March 23, 2021

Would something like this work for you?:
IF(OR(Value=95000, AND(Value>=92300, Value<=92399), etc..), true, false)


Not really, they’re not numbers but rather strings (postal codes can be all kind of weirdness), and the AND/OR is quite hard to read when there are more than 3 possibilities/combinations.


Forum|alt.badge.img+3
  • Author
  • Inspiring
  • March 23, 2021

I was able to do what I was looking for using regexes.

Formula "isPostalCodeAroundParis":

REGEX_MATCH(fieldName, '^(78280|91400|920[0-9]{2}|932[0-9]{2}|93460|940[0-9]{2}|9500[0-9]{1}|95800)$')