Excel IF Function Explained with Examples

Last Updated on 06/03/2025
Reading time: 2 minutes

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?

  1. Logical test: It's the key part of your function
  2. Answer when the logical test is TRUE
  3. 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.

Logical test vs IF function
  • 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.
Presentation IF function with text

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"
Reverse the logical test and switch the 2 and 3 arguments

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)

Difference between two cells in the IF function

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.
Third argument of the IF function missing

Nested IF

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

Leave a Reply

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

Excel IF Function Explained with Examples

Reading time: 2 minutes
Last Updated on 06/03/2025

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?

  1. Logical test: It's the key part of your function
  2. Answer when the logical test is TRUE
  3. 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.

Logical test vs IF function
  • 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.
Presentation IF function with text

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"
Reverse the logical test and switch the 2 and 3 arguments

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)

Difference between two cells in the IF function

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.
Third argument of the IF function missing

Nested IF

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

Leave a Reply

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