Skip to main content

OR

Use the OR function to determine if at least one condition in a test is TRUE.

Use

OR( condition1 [, condition2], ... )
Returns TRUE if any logical condition is TRUE.

ParameterRequiredDescription
condition1Yesthe initial condition to test, which must result in either TRUE or FALSE
[, condition2], ...Noadditional conditions to test, which must result in either TRUE or FALSE

ReturnsLogical

Examples

Restricting Date Selection to Weekends

You can use the OR function in an Output Validation Formula to ensure that a user-selected date falls only on a Saturday or a Sunday. This is done by combining OR with the WEEKDAY function, which returns a number from 1 (Sunday) to 7 (Saturday).

  • Scenario: A "Weekend Maintenance" request form must only allow dates that occur on a Saturday or Sunday.
  • Formula: OR(WEEKDAY(this) = 1, WEEKDAY(this) = 7).
  • Logic:
    • WEEKDAY(this) = 1: Checks if the date is a Sunday.
    • WEEKDAY(this) = 7: Checks if the date is a Saturday.
  • Result: If the user selects a Saturday, the first condition is FALSE but the second is TRUE; because one is true, the OR function returns TRUE, and the validation passes.

Flexible Pattern Matching for Arrays

The OR function is effective for validating arrays (collections of values) when each item in that array must conform to one of several allowed formats.

  • Scenario: You are capturing a list of "System IDs" in an array, and every entry must start with either the prefix "abc" or the prefix "xyz".
  • Logic Context: This would be used in conjunction with functions like COUNTIF or REGEX_MATCH to evaluate the contents of the array.
  • Formula Concept: OR(BEGINS(item, "abc"), BEGINS(item, "xyz")).
  • Result: The logic evaluates each item. If an item starts with "abc," the OR function identifies a match and returns TRUE. Similarly, if it starts with "xyz," it also returns TRUE. The validation only returns FALSE if an item fails to meet both criteria.

Pro Tip: The OR function can handle more than two conditions. You can string together many tests (e.g., OR(cond1, cond2, cond3, cond4)) to create highly sophisticated logic that remains valid as long as a single part of the formula is satisfied.