Cellwise

Unit 4 of 12

Logic with IF

Make your sheet decide things.

Functions in this unit: IF, AND, OR, IFS

Key ideas

IF asks a yes or no question

=IF(B2>=70,"Pass","Fail")

Test first, then the result when true, then the result when false.

Text needs quotes

"Pass"

Words inside a formula go in double quotes. Numbers and cell references do not.

AND / OR combine tests

=IF(AND(C2>=90,D2>=40),"Bonus","No")

AND needs every test true. OR needs at least one.

Lesson 1: IF basics

  1. What is the correct order of IF arguments?

    • Test, value if true, value if false
    • Value if true, test, value if false
    • Test, value if false, value if true
    • Value if false, value if true, test
    Show answer

    Test, value if true, value if false. IF(test, yes, no).

  2. A score of 70 or more passes. In C2, show "Pass" or "Fail", and make it work filled down to C7.

    ABC
    1StudentScoreResult
    2Maya92
    3Leo67
    4Priya85
    5Sam58
    6Nora70
    7Eli96

    Hint: =IF(B2>=70,"Pass","Fail")

    Show answer

    =IF(B2>=70,"Pass","Fail") in C2. Note Nora scored exactly 70. >= includes 70, > would not.

  3. Build: show "Over" when B2 is above 100, otherwise "OK"

    Show answer

    =IF(B2>100,"Over","OK"). Text results need double quotes.

  4. What will B1 show?

    AB
    15

    B1 contains =IF(A1>5,"High","Low")

    Show answer

    Low. 5 is not greater than 5, so the false branch runs.

  5. Which operator means "not equal to"?

    • <>
    • !=
    • =/=
    • ><
    Show answer

    <>. Excel uses <> for not equal.

Lesson 2: AND and OR

  1. What will A1 show?

    A
    1

    A1 contains =AND(TRUE,FALSE)

    Show answer

    FALSE. AND is only TRUE when every test is TRUE.

  2. A bonus needs a Score of 90+ AND 40+ Hours. Show "Bonus" or "No" in E2, filling down to E7.

    ABCDE
    1NameDeptScoreHoursBonus
    2AvaSales9442
    3BenSupport8138
    4CaraSales8845
    5DevOps9736
    6EvaSupport9141
    7FinnOps7344

    Hint: Put AND(...) where the test goes inside IF.

    Show answer

    =IF(AND(C2>=90,D2>=40),"Bonus","No") in E2. Ava and Eva qualify. Dev scored 97 but worked only 36 hours.

  3. What does OR(A, B) return?

    • TRUE if at least one test is TRUE
    • TRUE only if both are TRUE
    • TRUE if both are FALSE
    • The larger of A and B
    Show answer

    TRUE if at least one test is TRUE. OR needs just one TRUE.

  4. Flag a product "Review" if Region is "West" OR Units are over 200. Otherwise show "OK". Start in E2, fill to E7.

    ABCDE
    1ProductRegionUnitsPriceFlag
    2NotebookEast1203.5
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: =IF(OR(B2="West",C2>200),"Review","OK")

    Show answer

    =IF(OR(B2="West",C2>200),"Review","OK") in E2. OR inside IF is a common way to flag rows for a second look.

  5. What will A1 show?

    A
    1

    A1 contains =OR(3>5,2=2)

    Show answer

    TRUE. 3>5 is FALSE but 2=2 is TRUE, so OR is TRUE.

Lesson 3: Nested decisions

  1. Give a letter grade in C2: 90+ is "A", 80+ is "B", anything else "C". Fill to C7.

    ABC
    1StudentScoreGrade
    2Maya92
    3Leo67
    4Priya85
    5Sam58
    6Nora80
    7Eli96

    Hint: Put a second IF in the false slot of the first: =IF(B2>=90,"A",IF(B2>=80,"B","C"))

    Show answer

    =IF(B2>=90,"A",IF(B2>=80,"B","C")) in C2. Check the highest bar first, then work down.

  2. What problem does IFS solve?

    • It avoids deeply nested IFs by listing test/result pairs
    • It sums with conditions
    • It handles errors
    • It looks up values
    Show answer

    It avoids deeply nested IFs by listing test/result pairs. IFS(test1, result1, test2, result2, ...) reads top to bottom.

  3. What will B1 show?

    AB
    175

    B1 contains =IF(A1>=90,"A",IF(A1>=70,"B","C"))

    Show answer

    B. 75 fails the first test, passes the second.

  4. Show "Over" if Actual is greater than Budget, otherwise "Under". Start in D2 and fill to D7.

    ABCD
    1CategoryBudgetActualStatus
    2Groceries600684.35
    3Rent15001500
    4Transport250198.4
    5Dining200262.9
    6Utilities180171.25
    7Fun15095

    Hint: Compare Actual (C) to Budget (B).

    Show answer

    =IF(C2>B2,"Over","Under") in D2. Groceries and Dining are over budget. Rent is exactly on budget, so it shows Under.

  5. Build the same grade logic with IFS

    Show answer

    =IFS(B2>=90,"A",B2>=80,"B",TRUE,"C"). TRUE as the last test acts as "everything else".