Sub topic 7
Testing Several Conditions with AND, OR, and NOT
Prerequisites: you should know how to enter formulas, use cell references such as B2, and write a basic IF(test, value_if_true, value_if_false) formula.
A basic IF checks one condition. Real spreadsheets often need several conditions. Google Sheets provides three logical functions for this:
ANDreturnsTRUEonly when every condition is true.ORreturnsTRUEwhen at least one condition is true.NOTreverses a result. It changesTRUEtoFALSEandFALSEtoTRUE.
You can place these functions inside an IF test.
Use AND when every condition must pass
Suppose a student must score at least 50 on both a theory test in B2 and a practical test in C2. Use AND when both requirements are necessary.
=IF(AND(B2>=50, C2>=50), "Pass", "Fail")The AND function receives two comparisons. It returns TRUE only if both scores are at least 50. The surrounding IF then returns Pass or Fail.
| Theory score | Practical score | AND result | IF result |
|---|---|---|---|
| 72 | 48 | FALSE | Fail |
| 61 | 77 | TRUE | Pass |
You can combine more than two conditions:
=IF(AND(B2>=50, C2>=50, D2="Submitted"), "Complete", "Incomplete")This result is Complete only when both scores meet the threshold and the status in D2 is exactly Submitted.
Use OR when any condition is enough
Suppose a support request needs urgent attention when it is either marked Urgent in A2 or has been open for more than seven days in B2.
=IF(OR(A2="Urgent", B2>7), "Review now", "Normal queue")If either comparison is true, OR returns TRUE. This formula therefore marks these rows for immediate review:
- An urgent request opened two days ago.
- A normal request opened ten days ago.
- An urgent request opened ten days ago.
A row is placed in the normal queue only when both conditions are false.
Use NOT to reverse a condition
NOT is useful when the rule is easier to state as an exception. For example, mark a task as ready when it is not blocked.
=IF(NOT(A2="Blocked"), "Ready", "Hold")If A2 contains Blocked, the comparison is TRUE, but NOT changes it to FALSE, so the formula returns Hold. For any other value, it returns Ready.
You can also combine NOT with AND or OR:
=IF(AND(B2>=50, NOT(C2="Missing")), "Eligible", "Check record")This formula requires a passing score and a value in C2 that is not Missing.
Common errors
A frequent mistake is choosing OR when every requirement must be satisfied. If a student needs two passing scores, OR would incorrectly pass a student who passed only one test.
Text comparisons also require quotation marks:
=IF(OR(A2="Paid", A2="Waived"), "Closed", "Open")Without quotes, Sheets treats Paid and Waived as names or references instead of text values.
Use parentheses to make the logic clear. This formula requires a passing score and either an approved or a pending status:
=IF(AND(B2>=50, OR(C2="Approved", C2="Pending")), "Process", "Hold")Test each inner condition separately if the final result seems wrong. Check the spelling, spaces, number types, and whether the rule really requires all conditions or only one.
Exercise
Write a formula that returns "Discount" when a customer is either a member in B2 or has placed at least 10 orders in C2. Otherwise, return "Standard".
Show answer
=IF(OR(B2="Member", C2>=10), "Discount", "Standard")