Forms, fields and formulas

How do I write else-if, several OR values, or a "contains" check in a formula?

Nest IF for else-if, chain || for more than two OR conditions, use find() for contains, and add brackets to control order.

How-to

Short answer: Nest IF() for else-if. Use || or && to combine more than two conditions. Use find() to check whether text contains a value. Add brackets so arithmetic runs in the order you want.

Why it happens

  • There's no else-if keyword. Each extra branch is another IF in the false value.
  • or() and and() take only two conditions. || and && take any number. See logical expressions.
  • The formula builder has no contains() function.

How to fix it

Replace the field IDs in these examples with your own.

  1. Else-if: IF(Food_rating > 5, "Yummy", IF(Food_rating > 3, "OK", "Yucky"))
  2. Match a dropdown value: IF(Photo_ID_Type = "Driver's License", "X", ""). The text must match exactly, including case.
  3. Several OR values: IF(Region = "EMEA" || Region = "APAC" || Region = "LATAM", "Global", "Local")
  4. Text contains: IF(Text1.find("x3"), "Yes", "No"). See find.
  5. Checkbox contains: IF(Regions.has("EMEA"), "Yes", "No"). See list expressions.
  6. Arithmetic order: multiplication and division run before addition and subtraction. Use brackets, for example (Total - Discount) + VAT.
  7. Percentage by condition: IF(GST = true(), Amount + (Amount * 0.05), IF(VAT = true(), Amount + (Amount * 0.20), 0)), where GST and VAT are Yes/No fields.

Tip

Click Evaluate in the formula builder to test a formula with sample values before you save it.

Related answers