How to use if on multiple conditions
Tutor 5 (50 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
An IF with multiple conditions evaluates two or more logical tests and returns different results depending on whether those tests are true or false. Use logical functions such as AND, OR, NOT, IFS, or nested IF to combine tests inside one formula.
Why use multiple-condition IF formulas?
Multiple-condition IF formulas replace many manual checks by returning a single computed result. Use them to categorize data, assign grades, compute tiered commissions, validate inputs, or pick between alternative actions based on several criteria.
Basic building blocks
-
IF(logical_test, value_if_true, value_if_false)— single condition. -
AND(cond1, cond2, ...)— returns TRUE only when every condition is TRUE. -
OR(cond1, cond2, ...)— returns TRUE when any condition is TRUE. -
NOT(cond)— reverses a logical value. -
IFS(cond1, result1, cond2, result2, ...)— evaluates conditions in order and returns the first matching result (available in Excel 2016+ and Excel for Microsoft 365). -
SWITCH(expression, value1, result1, value2, result2, ..., default)— compares an expression to values and returns a matching result (available in recent Excel builds).
How to combine IF with AND and OR
-
Test that both A1 is greater than 10 and B1 equals "Yes":
=IF(AND(A1>10, B1="Yes"), "Pass", "Fail")
-
Test that either A1 is blank or C1 is less than 0:
=IF(OR(A1="", C1<0), "Check", "OK")
When to use nested IF versus IFS
-
Use
IFSfor many sequential, mutually exclusive checks because it is cleaner and easier to read. -
Use nested
IFwhen backward compatibility with very old Excel versions is required. -
Example with nested
IF(three tiers):=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))
-
Equivalent using
IFS:=IFS(A1>=90, "A", A1>=80, "B", A1>=70, "C", TRUE, "F")
How to test multiple conditions that are not mutually exclusive
-
Return different text depending on two independent flags in B1 and C1:
=IF(AND(B1="Y", C1="Y"), "Both", IF(OR(B1="Y", C1="Y"), "One", "None"))
-
When actions depend on counts of true conditions, convert booleans to numbers and sum them:
=IF( (N(B1="Y") + N(C1="Y") + N(D1="Y")) >= 2, "At least two true", "Less than two")
Use
--(condition)in place ofN(...)where preferred:=IF( (--(B1="Y") + --(C1="Y") + --(D1="Y")) >= 2, "At least two true", "Less than two")
How to use IF with text, blanks, and errors
-
Check for blank cells:
=IF(A1="", "No entry", "Has entry")
-
Protect against errors using
IFERROR:=IFERROR( IF(A1=0, "Zero", B1/A1 ), "Calculation error" )
How to apply IF across ranges (multiple rows)
-
Put formula in the first row and fill down.
-
For array-like calculations without helper columns, use
SUMPRODUCT,COUNTIFS, orFILTER(modern Excel) instead of complex nested IFs:=SUMPRODUCT(--(A2:A100>10), --(B2:B100="Yes"))
That example counts rows where both conditions are true.
Performance and readability tips
-
Keep formulas short by moving complex calculations into helper columns when many logical steps are required.
-
Prefer
IFSover deeply nestedIFfor readability. -
Use named ranges to make conditions self-documenting.
-
Avoid volatile functions such as
INDIRECTinside many IFs when performance matters.
Can I test multiple conditions with a single IF?
Yes. Use AND or OR inside the logical_test argument to evaluate several conditions within a single IF.
Example:
=IF(AND(A1>0, B1<100, C1="Active"), "Valid", "Invalid")
Do Windows and Mac Excel behave differently here?
No significant functional differences exist for IF, AND, OR, IFS, or IFERROR in current Excel releases on Windows and Mac.
Differences to note:
-
Older Excel versions required array formulas to be entered with Ctrl+Shift+Enter on Windows and Control+Shift+Enter on Mac. Modern Excel with dynamic arrays no longer requires that.
-
Keyboard shortcuts and menu locations may differ between platforms.
Examples: common real-world scenarios
-
Two-condition pass/fail (score and attendance):
=IF(AND(Score>=60, Attendance>=75%), "Pass", "Fail")
- Tiered commission based on sales:
Flag rows needing review when either quantity is negative or date is missing:
Troubleshooting common mistakes
-
Mismatch of data types: Ensure numeric comparisons use numbers, not text-formatted numbers.
-
Incorrect quotes: Use straight double quotes
""for text comparisons. -
Order of conditions: Place the most restrictive tests first when using
IFSor nestedIF. -
Missing absolute references: Use
$when filling formulas that reference a fixed cell or range.
Quick reference cheatsheet
-
Both true:
AND(cond1, cond2)insideIF. -
Any true:
OR(cond1, cond2)insideIF. -
Multiple exclusive tiers:
IFS(...)or nestedIF. -
Count rows meeting many tests:
COUNTIFS(range1, crit1, range2, crit2, ...). -
Sum with multiple conditions:
SUMIFS(sum_range, criteria_range1, crit1, ...)orSUMPRODUCTfor complex logic.
Final recommended pattern
-
Use
IFSfor clarity when your Excel supports it. -
Use
ANDandORwhen combining logical tests insideIF. -
Use helper columns and named ranges to keep formulas readable and maintainable.
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
Why is today function not working
Answers · 1
How to extract date from datetime in excel
Answers · 1
Why is the date value not working
Answers · 1
How to create a date formula
Answers · 1