Excel Tutorial
Excel tutorials, quizzes & AI guides — all levels
RSS
  • Online Excel Exercises
  • Training
  • Excel Tests
  • Sitemap
  • Premium Quizzes
  • Shop
  • My account

Excel IF Function Explained with Examples

Conditional
Reading time: 2 minutes
Views: 30,937

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.

  • 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
    • Logical Test – Beginner Level
    • Logical Test – Intermediate Level
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.

Frédéric LE GUEN

beginner, Condition, IF function, logical test, Top 10

Leave a Reply Cancel reply

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

Most Viewed Posts

  • Displaying Negative Numbers in Parentheses in Excel (310,065)
  • Top 10 Excel Functions You Must Know (232,001)
  • How to make automatic calendar in Excel (212,775)
  • Dash for a zero in Excel automatically (190,812)
  • Converting a Date from YYYYMMDD to DD/MM/YYYY in Excel (171,033)
image excel exercises
Excel Exercises
image excel quizzes
Excel Quizzes

Excel IF Function Explained with Examples

Reading time: 2 minutes
Views: 30,937

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.

  • 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
    • Logical Test – Beginner Level
    • Logical Test – Intermediate Level
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.
Tags: beginnerConditionIF functionlogical testTop 10

Frédéric LE GUEN

Leave a Reply Cancel reply

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

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net