The IF function in Excel is the first function for decision-making. It checks a condition and returns one value if the condition is true and another value if it is false. It is one of the Top 10 Excel Functions You Must Know.
This article has been written by a human, not ChatGPT. The examples, explanations, and screenshots will help you build and use the IF function in your workbook.
How to build an IF function?
- Logical test: It's the key part of your function
- Answer when the logical test is TRUE
- Answer when the logical test is FALSE
=IF(logical_test,answer_true,answer_false)
Difference Between IF Function and a Logical Test
Many people misunderstand the difference between an IF Function and a Logical Test.
- The logical test compares 2 items and returns TRUE or FALSE
- You can directly write a logical test in a cell
=B2=C2
- In the following link, you can practice logical tests in many situations

- Return TRUE or FALSE as a result that doesn't explain the test's purpose 🤔
- So, the IF function will be useful to "explain" the result by replacing TRUE or FALSE with "Correct" or "Wrong".
- The function's first argument is the same logical test as the previous example.
- But now, when the test is TRUE, the IF function returns "Correct", the function's second argument.

Deep dive with the IF function
But it's important to understand that there is not a unique solution. In the same situation, we can reverse the test B2<>C2
and, of course, switch the 2nd and 3rd arguments. And the result in the cells is the same.
- Row 2: does B2 is different (
<>
) of C2? - No. Then, returns the 3rd argument, "Correct"

Let's go further. We can also replace the different parts of the function with calculations. For instance, instead of returning words, we can return the difference between the amount received and the amount expected =IF(B2<>C2,C2-B2,0)

To conclude, we can "hide" the result when the result of the logical test is FALSE, to avoid to display 0. But the mistake will be to write the IF function with 2 arguments only.
- If you omit the 3rd argument, the IF function displays FALSE.
- That's perfectly correct!
- Remember, the purpose to return a custom result when the logical test is TRUE or FALSE
- If you omit the 3rd argument, well, you return the result of the logical test, so FALSE
- If you want to return "nothing" or an empty cell when the test is FALSE
- You must fill the 3rd argument; never let it empty
- Write
""
(2 double-quotes without a space) which means empty string.

Nested IF
- A nested IF is when you use an IF function inside another IF function. This is useful for multiple conditions.