No history yet

Logical Functions

Making Decisions in Excel

Spreadsheets don't just hold data; they can also make decisions based on it. The simplest way to do this is with the IF function. It performs a logical test and then returns one value if the test is true, and another if it's false.

Think of it as asking a simple yes-or-no question. The structure is: =IF(logical_test, value_if_true, value_if_false)

  • logical_test: The condition you want to check (e.g., A1 > 50).
  • value_if_true: What to show if the condition is met.
  • value_if_false: What to show if the condition is not met.

For example, let's say we want to determine if a student passed a test. The passing score is 60. If a student's score in cell B2 is 60 or higher, they pass. Otherwise, they fail.

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

Here's how that looks in a table.

StudentScoreStatus
Anya85Pass
Ben58Fail
Carla92Pass
David60Pass

Handling Multiple Conditions

The IF function is great for two outcomes, but what about when you have more? For instance, assigning letter grades (A, B, C, D, F) requires checking multiple conditions. For years, the solution was to nest IF functions inside each other.

A nested IF statement places another IF function in the value_if_false argument of the first one. It creates a chain of decisions. If the first condition isn't met, it moves to the next, and so on.

Let's assign grades based on these rules:

  • 90 or above: "A"
  • 80 to 89: "B"
  • 70 to 79: "C"
  • 60 to 69: "D"
  • Below 60: "F"
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", IF(B2>=60, "D", "F"))))

As you can see, this gets complicated quickly. It's easy to lose track of all the parentheses and the logic becomes difficult to read. It works, but there's a better way.

A Cleaner Approach with IFS

Modern Excel offers the IFS function, which is designed specifically for checking multiple conditions. It's much cleaner and easier to understand than a long chain of nested IFs.

The structure is a series of test-and-value pairs: =IFS(logical_test1, value_if_true1, logical_test2, value_if_true2, ...)

Excel checks each condition in order. As soon as it finds one that is true, it returns the corresponding value and stops. Let's rewrite our grading formula using IFS.

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

This formula does the exact same thing as the nested IF statement, but it's far more readable. Each condition and its result are listed side-by-side. The order is important, as IFS will stop at the first true condition it finds. That's why we start with the highest score and work our way down.

Rule of thumb: Use IF for binary (true/false) outcomes. For anything more complex, IFS is almost always the better choice.

Now that you understand the mechanics, it's time to check your knowledge.

Quiz Questions 1/4

What are the three arguments of the IF function, in the correct order?

Quiz Questions 2/4

What is the primary advantage of using the IFS function compared to a series of nested IF functions?

Mastering these logical functions allows you to automate decisions and categorize data efficiently, making your spreadsheets much more powerful.