FxFormula Drills

IF with AND and OR

IF returns one value when a test is true and another when it is false. AND is true only when every argument is true, so IF(AND(score>=70, region="East"), "Bonus", "No") pays the bonus only to an East score of at least 70. OR is true when any argument is true. Put AND or OR in the test position of IF. They are not a substitute for IFS when you have several different results.

Syntax

IF

IF(logical_test, value_if_true, value_if_false)

The test is a comparison or an AND, OR, or NOT call. Text results go in quotes. If you omit value_if_false, a failed test returns FALSE.

AND

AND(logical1, [logical2], ...)

TRUE only when every argument is TRUE. A single FALSE makes the whole AND false. Use it inside IF when a row must pass a list of tests.

OR

OR(logical1, [logical2], ...)

TRUE when at least one argument is TRUE. Use it when several values are acceptable, such as East or West.

Comparison

QuestionIFAND inside IFOR inside IF
Question it answersOne test, two possible resultsDid every test pass?Did at least one test pass?
Score at least 70Pass or FailNot enough if region also mattersToo loose if region also matters
Score at least 70 and EastNeeds AND in the testThe right combinationWould also pay West
East or WestNeeds OR, or two IFsWould require both regions at onceThe right combination
VersionsAll current Excel and Google SheetsAll current Excel and Google SheetsAll current Excel and Google Sheets

Worked examples

A bonus that requires a score and a region

82 in the East qualifies. 64 in the West does not, because the score is under 70 even though OR would have accepted the region. 91 in the East passes the score test alone.

Scores 82, 64, 91, and 49. Regions East, West, East, and North.
RowAB
1ScoreRegion
282East
364West
491East
549North
  • =IF(A2>=70,"Pass","Fail") → Pass
  • =IF(A3>=70,"Pass","Fail") → Fail
  • =IF(AND(A2>=70,B2="East"),"Bonus","No") → Bonus
  • =IF(AND(A3>=70,B3="West"),"Bonus","No") → No
  • =IF(OR(B3="East",B3="West"),"Yes","No") → Yes
  • =IF(OR(B5="East",B5="West"),"Yes","No") → No

The plain IF only looks at the score, so 82 passes and 64 fails. AND adds the region. Row 2 is both at least 70 and East, so the bonus is paid. Row 3 fails the score test, so AND is false and the result is No. OR on the region ignores the score: West is one of the accepted regions, North is not.

When to use which

Use a plain IF for one cutoff

Pass or fail, over quota or not, late or on time. The free pass-or-fail drill is this formula. Add AND or OR only when a second fact changes the answer.

Use AND when you would say 'both'

Eligible and in the East region. Paid and shipped. Every test is required. One failure returns the false branch.

Use OR when you would say 'either'

East or West, cash or card. Do not use AND for a list of acceptable labels. AND of two different region tests is never true.

Common mistakes

Writing IF(A2>=70 AND B2="East")

Excel does not accept AND as a word between comparisons. The function call has to wrap them: IF(AND(A2>=70, B2="East"), "Bonus", "No").

Repeating the cell in a range comparison that is not a range

OR(B2="East", B2="West") repeats the cell on purpose, once per acceptable value. AND(B2="East", B2="West") asks one cell to be both names and is always false.

Forgetting quotes around text results

"Bonus" is text. Bonus without quotes is a name Excel tries to resolve, which becomes #NAME? if no such name exists.

Nesting a new IF for every extra result

AND and OR still produce one true branch and one false branch. Three different letter grades are nested IF or IFS, not a deeper AND.

Versions and compatibility

IF, AND, and OR are in every Excel version you are likely to open, and in Google Sheets. The formulas on this page do not need Microsoft 365.

IFS, which handles several different results without nesting, needs Excel 2019 or later, Microsoft 365, or Google Sheets. The nested-IF and IFS pages cover that choice.

Comparisons are not case-sensitive for text. "East" and "east" match.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

Can AND and OR stand outside IF?

Yes. In a cell of their own they return TRUE or FALSE. Inside IF they become the test that picks between two results. A drill usually wants the IF, because the graded cell is a label such as Bonus or Pass.

How do I require a score and allow two regions?

Combine them: IF(AND(A2>=70, OR(B2="East", B2="West")), "Bonus", "No"). The OR is one argument of the AND. The score test is the other.

What happens if I omit the false result?

IF returns FALSE when the test fails. That is a poor label on a report. Type the third argument.

Do blank cells count as zero?

A blank compared with >=70 is not true. AND including that comparison is false. Do not rely on a blank to mean zero unless you have decided that on purpose and tested it.