Mastering the OR Function in Google Sheets
Learn how to use the OR function in Google Sheets to test multiple conditions with clear syntax, practical examples, and best practices for formulas, filters, and conditional formatting.
The OR function in google sheets evaluates multiple conditions and returns TRUE if any of them are TRUE. It’s ideal for building flexible logic across sheets, filters, and conditional formatting. This guide explains the syntax, provides practical examples, and shows how OR interacts with IF, FILTER, and other functions to streamline decision-making in spreadsheets.
What the OR function does in Google Sheets
The OR function tests several logical expressions and returns TRUE if any one of those expressions evaluates to TRUE. If all expressions are FALSE, OR returns FALSE. This makes OR a cornerstone of multi-condition decision logic in Google Sheets, enabling you to trigger actions based on several possible scenarios in one formula.
=OR(A2>10, B2="Yes", C2>=100)In this example, the result is TRUE if A2 is greater than 10, or B2 equals the text "Yes", or C2 is at least 100. The function is commonly used inside IF for conditional outcomes:
=IF(OR(A2>10, B2="Yes"), "Qualified", "Not qualified")- Here, the OR test determines which branch the IF will take
- You can extend OR with more conditions as needed
- Any non-logical inputs are coerced to logical values (nonzero numbers are TRUE, empty is FALSE)
Variations include combining OR with AND for more nuanced rules and wrapping OR inside other functions to drive multi-path logic.
OR syntax and basic usage
The basic syntax of OR is straightforward: =OR(logical1, [logical2, ...]). Each argument should resolve to TRUE or FALSE. You can mix numeric comparisons, text comparisons, and boolean values in a single OR call. A few practical examples help illustrate common patterns:
=OR(A2>0, B2<0)=OR(A2=TRUE, B2="TRUE")Tips:
- Any argument that cannot be evaluated as TRUE/FALSE is coerced to FALSE unless it’s a nonzero number (which is TRUE).
- You can reference entire columns, but be mindful of performance with large ranges.
When OR sees three or more conditions, it behaves identically to fewer conditions; there’s no special short-circuiting behavior in Sheets—each argument is evaluated, then OR combines the results.
Nesting OR with IF and IFS
Nesting OR inside IF is a common pattern to return different results based on multiple conditions:
=IF(OR(A2>10, B2="Yes"), "Qualified", "Not qualified")You can also pair OR with IFS for multi-branch decisions:
=IFS(OR(A2>10, B2="Yes"), "Match", TRUE, "No Match")Explanation:
- The OR inside IF decides which textual outcome to return
- In IFS, OR serves as a composite condition that triggers a specific branch when any sub-condition is TRUE
- Use TRUE as a catch-all else condition in IFS if you don’t have a final default
Variations include nesting OR inside LOOKUP-related formulas to expand search criteria and using OR with ARRAYFORMULA for array-driven decisions.
OR in data validation and conditional formatting
OR can power data validation rules to allow multiple acceptable inputs, and it can drive conditional formatting to highlight rows when any condition is met:
=OR($A1>0, $A1="Yes")Apply this as a custom formula for the range A1:A100 to highlight cells that are either positive numbers or the text Yes. For conditional formatting:
- Choose a format for cells that meet the rule
- Use a formula like
=OR($A1>0, $A1="Yes")as the custom formula - The $A1 reference ensures the rule applies correctly across the range
Practical tip: keep your ranges aligned with the data headers and ensure you anchor rows/columns correctly to avoid mis-highlighting.
OR with FILTER and QUERY
OR can power data extraction by widening criteria in FILTER or by embedding it in a QUERY statement:
=FILTER(A1:C100, (A1:A100>10) + (B1:B100="Yes"))This expression keeps rows where A > 10 OR B = "Yes". The addition operator between booleans converts TRUE to 1 and FALSE to 0, effectively simulating OR. You can also use QUERY for text-based OR logic:
=QUERY(A1:C100, "select A, B, C where A > 10 or B = 'Yes'", 1)Notes:
- In FILTER, sum-style boolean algebra is common for OR across ranges
- In QUERY, use the SQL-like
orkeyword for readability and compatibility
Both patterns scale well for larger datasets while keeping formulas readable.
Advanced patterns: OR with AND and NOT
Combine OR with AND to express more complex rules, such as "either A is true and C is false, or B is active":
=IF(OR(AND(A2>5, C2<20), B2="Active"), "OK", "Review")Another common use is negation with NOT to express exclusive conditions:
=IF(NOT(OR(A2>0, B2>0)), "None positive", "Some positive")Guidance:
- Use parentheses to control evaluation order clearly
- NOT is helpful for declaring when NONE of the conditions hold
- Mixing OR with NOT can implement robust guards in dashboards and models
Common pitfalls and debugging
OR is powerful, but misused patterns are common. Avoid applying OR directly to whole column ranges in large sheets, which can trigger performance issues. Also, OR with mixed data types may yield unexpected TRUE/FALSE results:
=OR(A2:A10>5, B2:B10<3)This returns an array error in many cases. Prefer:
=SUMPRODUCT(--(A2:A10>5), 1) + SUMPRODUCT(--(B2:B10<3), 0) > 0Or use BYROW with LAMBDA for row-by-row evaluation in newer Sheets:
=LET(r, BYROW(A2:B10, LAMBDA(row, OR(row(1)>0, row(2)="Yes"))), IF(OR(r), "At least one row matches", "None match"))Common gotchas:
- Ensure all logical arguments return TRUE/FALSE
- Align ranges in multi-range OR expressions
- Consider whether an array formula is appropriate for your use case
Real-world example: attendance eligibility
Suppose you track attendance and eligibility with two fields: either the employee is present, or they have an approved excused absence. You can formalize this with OR in a simple eligibility check:
=IF(OR(D2="Present", E2="Excused"), "Eligible", "Not eligible")This mirrors real-world HR rules where either condition grants eligibility. You can expand with AND for stricter rules, or nest in data validation to restrict inputs accordingly. Practical deployment often involves combining OR with lookups to create dynamic eligibility dashboards.
Performance considerations and best practices
When using OR across large datasets, keep formulas local to the necessary ranges and avoid volatile patterns. Favor explicit ranges over whole-column references when possible, and document the intent of each OR block so future editors understand the decision logic. For complex sheets, consider separating logic into named ranges or helper columns to improve readability and maintainability. If performance suffers, explore alternative strategies like FILTER with precomputed booleans or BYROW-based evaluation.
Step-by-step practical walkthrough (summary)
- Identify the conditions that should trigger a TRUE result (e.g., A > 10, status = "Yes").
- Write a basic OR to combine them:
=OR(A2>10, B2="Yes"). - Test in a simple IF:
=IF(OR(A2>10, B2="Yes"), "Flag", "OK"). - Extend to data validation or conditional formatting by applying the same OR logic to the target range.
- Use OR with FILTER/QUERY for data extraction across larger datasets.
- Validate edge cases where inputs differ in type or range size, and adjust with NOT/AND as needed.
- Document every OR block with comments or a helper cell to aid future edits.
Estimated time for this practical walkthrough: 30-45 minutes.
Steps
Estimated time: 30-45 minutes
- 1
Define your conditions
List the specific numeric or text tests you want to combine with OR. Write them as separate expressions so you can test them in isolation before combining.
Tip: Start with two conditions, then expand as needed. - 2
Create the OR formula
Write your OR statement with the desired logical tests inside the function. Ensure each argument resolves to TRUE or FALSE.
Tip: Keep each condition simple to avoid hard-to-trace errors. - 3
Wrap OR in IF for results
If you need a textual or numeric outcome, nest OR inside IF or IFS to produce the desired result.
Tip: Test with both TRUE and FALSE results to verify behavior. - 4
Apply to ranges
If using datasets, apply the same logic across a range with relative references and consider absolute references for anchors.
Tip: Anchor ranges properly to prevent misalignment when copying formulas. - 5
Leverage with FILTER/QUERY
Use OR within FILTER or in QUERY statements to extract data when multiple conditions apply.
Tip: Prefer FILTER for straightforward row filtering and QUERY for SQL-like queries. - 6
Validate and document
Add comments or helper cells to explain the logic and document edge cases in the sheet.
Tip: Documentation saves time for teammates inspecting the sheet later.
Prerequisites
Required
- Required
- Required
- A sample Google Sheet to practice onRequired
Optional
- Optional: Apps Script for advanced automationOptional
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| Copy | Ctrl+C |
| Paste | Ctrl+V |
| UndoReverts the last action | Ctrl+Z |
| RedoRe-applies the last undone action | Ctrl+Y |
FAQ
What does the OR function return in Google Sheets?
OR returns TRUE if any of its arguments evaluate to TRUE; otherwise it returns FALSE. It’s useful for testing several conditions simultaneously in formulas.
OR returns TRUE if any condition is true; otherwise, it returns false.
Can OR work with ranges?
OR typically takes individual logical expressions. Using it with whole-column ranges can cause errors. For range-based logic, combine OR with functions like SUMPRODUCT or use array-enabled patterns.
OR usually takes separate conditions; be careful with ranges and consider alternatives for array results.
How do I use OR with IF?
Wrap OR inside IF to choose between outcomes based on multiple conditions. Example: =IF(OR(A2>10, B2="Yes"), 'Pass', 'Fail').
Use OR inside IF to produce different results when any condition is true.
What is a practical application of OR in data validation?
In data validation, OR allows multiple valid inputs. For example, a custom formula like =OR($A1>0, $A1="Yes") validates either a positive number or the text Yes.
You can use OR in validation to accept multiple valid inputs.
How can OR be used with FILTER or QUERY?
OR can be used to broaden filter criteria, such as =FILTER(A1:C100, (A1:A100>10) + (B1:B100="Yes")). In QUERY, use OR in the WHERE clause: where A > 10 or B = 'Yes'.
Use OR to expand data extraction in FILTER or QUERY.
The Essentials
- Use OR to test multiple conditions in one formula
- Nest OR inside IF for conditional results
- In FILTER/QUERY, OR expands data extraction criteria
- Validate input types to avoid unexpected TRUE/FALSE results
