Logical Functions

Back

Loading concept...

Excel Logic Functions: Your Decision-Making Superpowers

The Magic Door Analogy

Imagine you’re standing in front of a magic door. This door has a special power—it can look at any situation and decide what to do. Should it open? Should it stay closed? Should it show you a secret message?

Excel’s logical functions are exactly like this magic door. They look at your data, make decisions, and give you answers—all in the blink of an eye!


The IF Function: The Simple Decision Maker

What Is It?

The IF function is like asking a yes/no question. If the answer is “yes,” one thing happens. If the answer is “no,” something else happens.

Think of it like this:

“IF it’s raining, take an umbrella. OTHERWISE, wear sunglasses.”

The Formula

=IF(condition, value_if_true, value_if_false)

Real Example

A B
Score Result
85 =IF(A2>=60,“Pass”,“Fail”)

Result: “Pass” (because 85 is greater than 60!)

How It Works

graph TD A["Is the score >= 60?"] -->|YES| B["Show 'Pass'"] A -->|NO| C["Show 'Fail'"]

Remember: IF has exactly 3 parts:

  1. The question (Is score >= 60?)
  2. The YES answer (“Pass”)
  3. The NO answer (“Fail”)

The AND Function: All Doors Must Open

What Is It?

AND is like having multiple locks on a door. Every single lock must be unlocked for the door to open.

Think of it like this:

“You can go to the party IF you finished your homework AND cleaned your room AND ate your vegetables.”

All three must be true!

The Formula

=AND(condition1, condition2, condition3...)

Real Example

=AND(A1>=18, B1="Yes", C1>0)

This checks:

  • Is age 18 or older? ✓
  • Did they agree? ✓
  • Is balance positive? ✓

Returns TRUE only if ALL are true!

Visual Understanding

graph TD A["Check #1: Age >= 18?"] -->|YES| B["Check #2: Agreed?"] A -->|NO| F["FALSE - Stop here!"] B -->|YES| C["Check #3: Balance > 0?"] B -->|NO| F C -->|YES| D["TRUE - All passed!"] C -->|NO| F

The OR Function: Any Door Will Do

What Is It?

OR is like having multiple ways to enter a building. If ANY door is open, you can get in!

Think of it like this:

“You get dessert IF you ate your vegetables OR finished your homework OR it’s your birthday.”

Just ONE needs to be true!

The Formula

=OR(condition1, condition2, condition3...)

Real Example

=OR(A1="VIP", B1>1000, C1="Premium")

Gets discount if:

  • They’re a VIP? OR
  • Spent over $1000? OR
  • Has Premium membership?

Returns TRUE if ANY one is true!

Compare AND vs OR

Scenario AND OR
TRUE, TRUE, TRUE TRUE TRUE
TRUE, TRUE, FALSE FALSE TRUE
TRUE, FALSE, FALSE FALSE TRUE
FALSE, FALSE, FALSE FALSE FALSE

Memory Trick:

  • AND = Strict teacher (everything must be perfect)
  • OR = Nice friend (just one thing is enough!)

The NOT Function: The Opposite Machine

What Is It?

NOT flips everything around. TRUE becomes FALSE. FALSE becomes TRUE.

Think of it like this:

“If the light is NOT on, it’s dark.”

The Formula

=NOT(condition)

Real Example

=NOT(A1="Complete")
  • If A1 says “Complete” → Returns FALSE
  • If A1 says anything else → Returns TRUE

When Is This Useful?

=IF(NOT(A1=""), "Has data", "Empty!")

This checks: “If the cell is NOT empty, it has data!”


Nested IF Functions: Decisions Inside Decisions

What Is It?

Sometimes one question leads to another question. That’s a nested IF—an IF inside another IF!

Think of it like this:

“IF you’re hungry, THEN IF you want something sweet, eat cake, OTHERWISE eat pizza. OTHERWISE don’t eat.”

The Formula

=IF(condition1,
   IF(condition2, result2a, result2b),
   result_if_false)

Real Example: Grading System

=IF(A1>=90, "A",
   IF(A1>=80, "B",
      IF(A1>=70, "C",
         IF(A1>=60, "D", "F"))))

How It Works

graph TD A["Score >= 90?"] -->|YES| B["Grade: A"] A -->|NO| C["Score >= 80?"] C -->|YES| D["Grade: B"] C -->|NO| E["Score >= 70?"] E -->|YES| F["Grade: C"] E -->|NO| G["Score >= 60?"] G -->|YES| H["Grade: D"] G -->|NO| I["Grade: F"]

Tips for Nested IFs

  1. Start with the highest value first (90, then 80, then 70…)
  2. Maximum depth: Excel allows up to 64 nested IFs
  3. Use IFS instead if you have many conditions (easier to read!)

The IFS Function: The Better Way

What Is It?

IFS is the cleaner, easier version of nested IF. Instead of putting IF inside IF inside IF, you just list all your conditions!

Think of it like this:

“Check condition 1, then condition 2, then condition 3… and stop at the first TRUE one!”

The Formula

=IFS(condition1, result1,
     condition2, result2,
     condition3, result3,
     TRUE, default_result)

Real Example: Same Grading System

=IFS(A1>=90, "A",
     A1>=80, "B",
     A1>=70, "C",
     A1>=60, "D",
     TRUE, "F")

Notice: We use TRUE at the end as a “catch-all” for everything else!

Compare: Nested IF vs IFS

Nested IF IFS
Harder to read Easy to read
Many parentheses Cleaner syntax
Easy to make mistakes Fewer errors
Works in old Excel Needs Excel 2019+

The SWITCH Function: The Label Matcher

What Is It?

SWITCH is like a vending machine. You press a button (give it a value), and it gives you exactly what matches!

Think of it like this:

“If you press 1, get chips. If you press 2, get candy. If you press 3, get water.”

The Formula

=SWITCH(value,
        match1, result1,
        match2, result2,
        match3, result3,
        default_result)

Real Example: Day Names

=SWITCH(A1,
        1, "Monday",
        2, "Tuesday",
        3, "Wednesday",
        4, "Thursday",
        5, "Friday",
        6, "Saturday",
        7, "Sunday",
        "Unknown")

If A1 = 3, result is “Wednesday”!

When to Use SWITCH vs IFS

Use SWITCH When Use IFS When
Comparing exact values Comparing ranges
Like matching codes Like grading scores
Example: Day numbers Example: Score >= 90

Visual Flow

graph TD A["What value do we have?"] --> B{Match found?} B -->|Value = 1| C["Return Monday"] B -->|Value = 2| D["Return Tuesday"] B -->|Value = 3| E["Return Wednesday"] B -->|No match| F["Return default"]

Combining Powers: AND, OR with IF

The Ultimate Combo

You can put AND and OR inside your IF statements!

Example 1: AND inside IF

=IF(AND(A1>=18, B1="Yes"),
   "Approved",
   "Denied")

Translation: “If age is 18+ AND they agreed, approve them!”

Example 2: OR inside IF

=IF(OR(A1="VIP", B1>1000),
   "Discount!",
   "Regular Price")

Translation: “If they’re VIP OR spent over $1000, give discount!”

Example 3: The Super Combo

=IF(AND(A1>=18, OR(B1="VIP", C1>1000)),
   "Special Access",
   "Standard Access")

Translation: “If they’re 18+ AND (either VIP OR spent over $1000), give special access!”


Quick Reference Summary

Function Purpose Example
IF One decision =IF(A1>10,"Big","Small")
AND All must be true =AND(A1>0, B1>0)
OR Any can be true =OR(A1="Yes", B1="Yes")
NOT Flip true/false =NOT(A1="Empty")
Nested IF Many decisions =IF(A1>90,"A",IF(A1>80,"B","C"))
IFS Clean many decisions =IFS(A1>90,"A",A1>80,"B",TRUE,"C")
SWITCH Match exact values =SWITCH(A1,1,"One",2,"Two","Other")

You’re Now a Logic Master!

You’ve learned how Excel thinks and makes decisions. These functions are the building blocks for creating smart spreadsheets that:

  • Grade students automatically
  • Calculate bonuses based on performance
  • Categorize data instantly
  • Make complex decisions in milliseconds

Remember the magic door: Every logical function is just asking questions and deciding what to do next. Now YOU control the door!

Loading story...

Story - Premium Content

Please sign in to view this story and start learning.

Upgrade to Premium to unlock full access to all stories.

Stay Tuned!

Story is coming soon.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.