No history yet

Logical Function Mastery

Making Decisions in Excel

Spreadsheets are great for calculations, but their real power comes from making decisions automatically. Instead of manually checking values and categorising them, you can teach Excel your rules. This is done with logical functions, which test whether a condition is true or false and then perform an action based on the result.

The core of this logic is the IF function. It works just like we do: If something is true, do one thing. If it's not, do something else.

The function takes three arguments: a logical test, what to do if the test is true, and what to do if the test is false. Let's say you want to check if a salesperson met their quarterly target of $50,000. If their sales are in cell B2, the formula would look like this:

=IF(B2>=50000, "Bonus", "No Bonus")

Here, B2>=50000 is the logical test. If it's true, Excel returns the text "Bonus". If it's false, it returns "No Bonus". This simple structure is the foundation for building much more complex logic into your spreadsheets.

Combining Conditions

Sometimes, a single condition isn't enough. You might need to check if multiple criteria are met, or if at least one of several criteria is true. This is where the AND, OR, and NOT functions come in. They are almost always used inside an IF function's logical test.

AND

conjunction

Checks whether all arguments are TRUE, and returns TRUE if all arguments are TRUE.

Imagine you want to award a bonus only if a salesperson hits their $50,000 target and has more than 10 new clients. With the sales figure in B2 and new clients in C2, you would combine AND with IF:

=IF(AND(B2>=50000, C2>10), "Bonus", "No Bonus")

Both conditions inside the AND function must be true for the whole test to be true. If either one is false, the salesperson gets no bonus.

The OR function is more flexible. It checks if any of its arguments are true. For example, an order might get priority shipping if its value is over $1,000 or if it's marked as 'Urgent'. With the order value in D2 and the status in E2, the formula is:

=IF(OR(D2>1000, E2="Urgent"), "Priority Shipping", "Standard Shipping")

Here, only one of the conditions needs to be true to trigger the "Priority Shipping" result.

Finally, the NOT function reverses the logical value of its argument. It turns TRUE into FALSE and FALSE into TRUE. It's useful for checking if a condition is not met. For instance, to flag all sales that are not from the 'North' region (in cell F2):

=IF(NOT(F2="North"), "Flag for Review", "OK")

Handling Complex Scenarios

What if you have more than two possible outcomes? For example, converting a numerical score into a letter grade (A, B, C, or F). A single IF function can't handle this. The traditional solution is to nest IF functions inside each other.

A nested IF places another IF function in the value_if_false part of the parent IF. This creates a chain of decisions.

To assign a grade based on a score in cell A2 (90+ is A, 80+ is B, 70+ is C, otherwise F), the nested IF formula looks like this:

=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "F")))

While nested IFs are powerful, they can: get complex and difficult to manage, slow down Excel with large datasets, and increase the risk of errors, which are hard to debug.

For situations with multiple conditions, Excel provides a cleaner, more modern function: IFS. It lets you list pairs of conditions and their corresponding outcomes. The IFS function stops at the first condition that evaluates to TRUE.

Here is the same grading logic using IFS:

=IFS(A2>=90, "A", A2>=80, "B", A2>=70, "C", A2<70, "F")

The logic is easier to read because you don't have to track nested parentheses. Each condition and its result are listed sequentially.

MethodFormulaReadability
Nested IF=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "F")))Can be confusing
IFS=IFS(A2>=90, "A", A2>=80, "B", A2>=70, "C", A2<70, "F")Clear and sequential

Managing Errors Gracefully

Formulas don't always produce a valid result. Dividing by zero gives a #DIV/0! error, and a failed lookup results in #N/A. These errors can look unprofessional and break other formulas that depend on them. The IFERROR function provides a clean way to handle these situations.

It checks if a formula results in an error. If it does, IFERROR returns a value you specify. If it doesn't, it returns the formula's original result.

Imagine you're calculating a sales commission percentage by dividing this month's sales (A2) by last month's sales (B2). If last month had zero sales, B2 would be 0, and the formula =A2/B2 would result in a #DIV/0! error.

To handle this, you wrap your formula in IFERROR:

=IFERROR(A2/B2, 0)

Now, if B2 is 0, the formula will return 0 instead of an ugly error message. You could also make it return a text string, like "No Prior Sales". This makes your financial models and reports much more robust and easier for others to understand.

Quiz Questions 1/5

What is the primary purpose of the IF function in a spreadsheet?

Quiz Questions 2/5

A company wants to flag employees for a performance review if their sales are below $20,000 and their client satisfaction score is below 70%. If sales are in A2 and satisfaction is in B2, which formula correctly identifies these employees?

These logical functions are the building blocks for automating tasks and creating intelligent, dynamic spreadsheets that respond to your data.