Lesson 9 / 1560%

Lesson 9

AND, OR and Nested Functions

18 min

Combine several conditions for richer calculation rules.

Definition

The AND,OR andNOT functions arelogical operators: they combine or invert conditions to produce a single result, either TRUE or FALSE. Functions are said to benested when they are placed inside one another (for example anANDinside an OR, itself inside an IF) in order to express complex decision rules.

Combining several conditions

The IF function only tests one condition at a time. To check thatseveral conditions are met simultaneously (or that at least one of them is), Excel offers the ANDand OR functions.

In everyday life, we reason this way all the time: "I'll go out if I have no more workand the weather is nice", or "I'll take the umbrella if it rains or if it's windy". A company's business rules (discounts, bonuses, file approvals) almost always rely on this kind of combination, and AND / OR let you translate them faithfully into a spreadsheet.

The AND function

AND returns TRUE only if all the given conditions are true. It takes just one false condition for the whole result to be FALSE. It accepts as many conditions as needed, separated by commas.

and-function.txt
=AND(B2>=10, C2="Present")
→ TRUE only if the score is ≥10 AND the attendance is "Present"
→ FALSE if either of the two conditions fails

=AND(B2>=10, C2="Present", D2<>"Excluded")
→ with three conditions, all three must be true at the same time

The OR function

OR returns TRUE as soon as at least one of the given conditions is true. It returns FALSE only if all the conditions are false at the same time. This "or" is inclusive: if both conditions are true, the result is still TRUE.

or-function.txt
=OR(B2="VIP", C2>1000)
→ TRUE if the customer is "VIP" OR if their amount exceeds 1000 (or both)
AND and OR functions in Excel

Summary: the truth table

For two conditions A and B, here are all the possible results. This small table lets you mentally check a formula before typing it.

truth-table.txt
A      B      AND(A,B)  OR(A,B)
TRUE   TRUE   TRUE      TRUE
TRUE   FALSE  FALSE     TRUE
FALSE  TRUE   FALSE     TRUE
FALSE  FALSE  FALSE     FALSE

Combining AND/OR with IF

On their own, AND andOR only return TRUE or FALSE. They are almost always combined withIF to display a more meaningful result. The AND or OR function then takes the place of IF's "condition" argument.

if-and-or.txt
=IF(AND(B2>=10, C2="Present"), "Approved", "Not approved")

=IF(OR(B2="VIP", C2>1000), "Priority customer", "Standard customer")

Read the first formula from the inside out: Excel first evaluatesAND(...), which gives TRUE or FALSE, then the IF uses that result to choose between "Approved" and "Not approved". Reading from the inside out is the key to understanding every nested formula.

A complete business example

Let's imagine a sales bonus rule: a salesperson receives a bonus if they made more than 50 sales AND generated revenue above €5,000, ORif they are identified as "Salesperson of the month".

business-example.txt
=IF(OR(AND(B2>50, C2>5000), D2="Salesperson of the month"), "Bonus", "No bonus")

To build such a formula without getting lost, proceed step by step: first write the condition that groups the sales and the revenue, test it on its own, then add the "Salesperson of the month" status, and finally wrap the whole thing in an IF. Here is how the formula reacts on three different profiles.

business-example-cases.txt
Salesperson 1: 60 sales, €7,000, normal status           → AND true            → "Bonus"
Salesperson 2: 30 sales, €2,000, "Salesperson of the month" → OR true (status)  → "Bonus"
Salesperson 3: 60 sales, €3,000, normal status           → AND false, status no → "No bonus"
AND and OR functions in Excel

The NOT function

NOT inverts the result of a condition: TRUE becomes FALSE, and vice versa. It is mostly useful for inverting a complex condition, for example the result of anAND or anOR.

not-function.txt
=IF(NOT(B2="Done"), "In progress", "Done")
(equivalent to =IF(B2<>"Done", "In progress", "Done"))

=NOT(AND(A2>0, B2>0))
→ TRUE if at least one of the two values is not strictly positive

Placing parentheses correctly

When you nest several functions, every opening parenthesis must have its closing parenthesis, and the position of these parentheses completely changes the meaning of the rule. Compare these two formulas, which do not express the same thing at all.

parentheses-meaning.txt
=OR(AND(A2>0, B2>0), C2>0)
→ true if (A2 and B2 are positive) OR if C2 is positive

=AND(OR(A2>0, B2>0), C2>0)
→ true if (A2 or B2 is positive) AND if C2 is positive

When you edit a formula, Excel colors each pair of parentheses: click inside the formula and see which parentheses match each other to check that each group of conditions is properly delimited.

Common mistakes to avoid

  • Writing a double comparison — 5<B2<10 does not work as it does in mathematics. You must write AND(B2>5, B2<10).
  • Forgetting the quotation marks — any text being compared, such as "Present", must be enclosed in double quotation marks.
  • Confusing AND and OR — a rule phrased with "or" in everyday language sometimes has to be written with AND, and vice versa. Always test with concrete cases.
  • Misplaced parentheses — they change the meaning of the rule, not just the syntax.
  • Wrong separator — in the English version of Excel, arguments are separated by a comma, not a semicolon (depending on your regional settings, Excel may expect a semicolon instead).

Readability

Beyond 2 or 3 nested conditions, a formula quickly becomes hard to read and to fix. In these cases, it is often better to split the calculation into several helper columns (one per condition), before combining everything in a final column.

This method also makes debugging easier: if the final result is wrong, you can look at the helper columns and immediately spot which condition is not behaving as expected. Once the rule is validated, you can always merge the columns into a single formula if needed.

Exercise

On a table of students with a "Score" column and an "Attendance" column (Present / Absent), create a column that displays "Approved" only if the score is ≥10AND the attendance is "Present". Test your formula with at least four different combinations (sufficient score or not, present or absent).

Going further

Rebuild the complete sales bonus example (sales, revenue, status) and check that the formula works correctly for at least 3 different scenarios. Then rewrite the same rule using helper columns, and finally add a condition withNOT to exclude salespeople whose status is "Suspended".