Go Back

Excel IF Function

Excel allows a user to use a logical expression in order to check if a condition is true. This is possible by using the IF function which returns Boolean TRUE or FALSE as a result. This step by step tutorial will assist all levels of Excel users in using the IF function.

Figure 1. The result of the IF function

Syntax of the IF Formula

The generic formula for the IF function is:

=IF(logical_test, value_if_true, value_if_false)

The parameters of the IF function are:

  • logical_test – a logical expression that we want to check
  • value_if_true – a value which the function returns if a logical_test is TRUE
  • value_if_false – a value which the function returns if a logical_test is FALSE.

Compare Two Numbers Using the IF Function

In our example, we want to get the check if 10 is greater than 2. In case this is true, we return the message “10 is greater than 2”, and if it’s lower “10 is lower than 2”.

The formula looks like:

=IF(10>2, "10 is greater than 2", "10 is lower than 2")

The parameter logical_test is 10>2, as we want to check if 10 is greater than 2. The value_if_true is “10 is greater than 2”, while the value_if_false is “10 is lower than 2”.

To apply the IF function, we need to follow these steps:

  • Select cell B3 and click on it
  • Insert the formula: =IF(10>2, "10 is greater than 2", "10 is lower than 2")
  • Press enter

Figure 2. Using the IF function to compare two numbers

The logical_test 10>2 is TRUE, so the IF function returns value_if_true. Therefore, the result in the cell B3 is “10 is greater than 2”.

Using the IF Function to Compare Two Cells

In this example, we will provide cells references to the function, instead of numbers. The example is similar, but now we put 2 in B3 and 10 in C3. The logical_test is now B3>C3. The value_if_true is “B3 is greater than C3”, while the value_if_false is “B3 is lower than C3”. In the cell D3, we want to get the result.

The formula is:

=IF(B3>C3,"B3 is greater than C3", "B3 is lower than C3")

To apply the IF function, we need to follow these steps:

  • Select cell D3 and click on it
  • Insert the formula: =IF(B3>C3,"B3 is greater than C3", "B3 is lower than C3")
  • Press enter

Figure 3. Using the IF function to compare two cells

Now the logical condition is FALSE since 2 is not greater than 10. Therefore, the result in the cell B3 is “B3 is lower than C3”.

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

Need help in excel formula - IF function
Solved by I. H. in 17 mins
need help using the if function in excel
Solved by C. C. in 26 mins
problems with a nested IF function in excel
Solved by G. J. in 30 mins

Leave a Comment

avatar