In this tutorial, we will learn how to use the IF function in Microsoft Excel. This function is one of the very useful logical function in Excel. It is used for test the logic and return value if true and value if false results.
Formula Syntax and Argument
Below is the formula syntax of IF.

IF Function has three arguements. These are;
logical_test: this is for testing the logic or statements. To test the logic we need logical operators.
[value_if_true] : this is for returning the value if the result of logic test is TRUE.
[value_if_false] : this is for returning the value if the result of logic test is FALSE.
Logical Operators
Before writing IF formula, it is important to understand the logical operators. Below table illustrates the logical operator symbols and their description.

Simple Logic Testing
Let’s look at a basic example of logic testing in Excel. In example below, there is “Apple” in the cell B2 and D2. You want to check whether the value in B2 and D2 are same. This “value in B2 and D2 are same” is the logic to test. For this you have to use the “=” (equal to) operator. In F2 cell, write =B2=D2, when you press Enter, it will return the result as TRUE. Because the value in B2 and D2 are same, i.e. “Apple”. But, if you change the value in D2, make it “Ball” for example, it will return FALSE. Because in this case, your logical statement is now incorrect or false. See below image illustration for more clarity.

Let’s look at a different example with numeric values.
There is a data of Item wise sales of 4 months. You want to test whether the month total sales of all items is greater than 100. For this you have to make a logical statement in mathematical form by using the greater than (>) operator. The logical statement is “=SUM(B2:B4)>100”. If the total is greater than 100, it will return TRUE and otherwise FALSE.

Final IF Statement or IF Function
In the formula syntax of IF, there is [value_if_true] and [value_if_false]. Notice the TRUE and FALSE keywords here. In the result of logic test above, we got either of TRUE or FALSE. So the use of IF function is to replace the TRUE or FALSE result by something else. This can be anything like text, numbers or formula.
Look in the below example, where I will replace the TRUE or FALSE results by some different text values.

See in the example, I have used the double quotation (“) before and after the texts. Note that the double quotation symbol is applicable only if you are giving the text string. It is not applicable for numeric value and formula.
See below in another example, how we can replace TRUE or FALSE result by using IF function.

IF Function with Formula
Let’s look at the example for how we can combine the formula or calculation inside IF function. Below example contains the purchase information of different customers. To provide additional discount to the customers, we have a condition here. The condition is, purchase value should be greater than or equal to Rs. 5000. We can calculate the applicable discount amount by IF function.

In the example, the “greater than or equal to” (>=) operator is used for logic testing. In the value if true, a formula is used to calculate the discount amount.
Practice Workbook
Download the practice workbook to learn the IF function.
