In this article, we will explore how IF function works in Excel. It is simple but very effective and useful. We will also explore how to add multiple conditions in an IF function. First we will explain how an IF function works, then we will go on to combine IF function with AND and OR functions. And at the end we will also look at nested IF functions.

IF Function

The IF function in Excel allows us to:

The function is:

The square brackets around value if true and value if false do mean they are optional fields. The function will still work if nothing is entered for those two fields. In that case, TRUE will return 0 and FALSE will return FALSE.

Here’s an example below. We have a list of clients’ ages but the data is very hard to be presented because we could have data ranging from around 5 to 85. Using a simple IF function, we can group clients’ ages into “minor” or “adults”:

If-function-Excel

Now we can use a COUNTIF function on column B to calculate the number of adults and minors in this list.

Value If True and Value If False

With [value if true] and [value if false], we have set a string for each in the example above. However we can make it dynamic and have a formula there too. Here’s a simple example:

If-function-formula-Excel

The formula we have in C2 is:

Explanation: We first have Excel check the status in Column B. If status is “Cancelled”, the logical statement will be TRUE hence F3 – Cancellation Fee of $75 will populate. If the status is not “Cancelled”, Excel will use VLOOKUP to search for the price in the Price Guide in E5:F9 for the relevant program in Column A.

What Logical Tests Can We Include?

In the example above, we used “less than” as the logical test but there are so many more we could do in Excel. It would be impossible to list them all down but to list a few, we could:

IF & AND Functions

Essentially with IF functions, we enter a logical test and if it is TRUE, the [value if true] will return. Alternatively [value if false] will return. With the AND function, we can add multiple conditions into the logical test. And the logical test will only return TRUE if all conditions are met. As an example:

IF-AND-Functions-Excel

Explanation: in this case, two conditions must be met, the cell on the left must not be (<>) “Saturday” and must not be “Sunday”. If both conditions are met, “Working Day” will populate. Otherwise it will be “Weekend”. And of course you can add more than 2 conditions into the AND functions.

IF & OR Functions

The OR function is very similar, except only one of the conditions needs to be met for the logical test to return TRUE. Let’s explore the same scenario above but this time we will use the OR function to reach the same outcome:

If-OR-Functions-Excel

Explanation: in this case, only one of the logical tests in the OR function needs to be TRUE. That is, if the cell on the left is “Saturday” OR “Sunday”, the cell will be populated with “Weekend”. Otherwise it will be “Working Day”. And again, we can add more than 2 logical tests in OR functions.

Nested IF Functions

So far we’ve only looked at IF functions with two possible outcomes. If TRUE then [value if true] will appear. If FALSE then [value if false] will appear. Things are not always so simple. What happens if you have more than 2 possible outcomes? Consider this example below:

If a staff is employed on a casual basis, there will be no bonus. There will also be no bonus if no KPIs are met. If one of the two KPIs are met and the staff is employed on a permanent basis, a Tier 2 bonus will be rewarded. And finally if both KPIs are met and the staff is employed on a permanent basis, a Tier 1 bonus will be rewarded:

Excel-Nested-If-bonus-Table

Excel-Nested-IF-Functions

Let’s break down this long formula:

Nested IFs, AND and OR functions

As shown above with the AND and OR functions, we can sometimes reach the same outcome with either functions. We can also use nested IF functions to reach the same result. But imagine how many times we would have to nest the IF functions when we could perhaps group all conditions into an OR function. The question to ask is how many possible outcomes there are. If there are more than two, you will most likely need to use nested IF functions. But if there are only two possible outcomes, you should most likely be able to group all the conditions into AND and OR functions.

Please feel free to leave a comment below if there’s more you would like us to go through in this topic!

Leave a Reply

Your email address will not be published. Required fields are marked *