How to use Excel IF Condition
Click here to download the excel file which contains below examples.
Description of Excel IF Condition Function
Excel IF Condition: This function will help to do a logical test and then if the test result is TRUE, we can assign a value. If the test results FALSE, we can assign another value. Basically, if we want to check 1=1, if it is TRUE we want the answer to show as “CORRECT” if it is FALSE then we want to show as “INCORRECT”.
The syntax of Excel IF Condition Function
IF(logical_test,[value_if_true],[value_if_false])
- 1^{st} Argument (Compulsory): logical_test
- 2^{nd} Argument(Optional): [value_if_true]
- 3^{rd} Argument(Optional):[value_if_false]
(For any Excel Function Syntax if we have square brackets then it is optional)
Arguments description of Excel IF Condition Function
- logical_test: 1^{st} Argument here we need to select any cells for the logical test or else can write the logical test.
- [value_if_true]: 2^{nd} Argument here we need to select any cell or update the value which we want to show if the logical test in 1^{st} argument result is TRUE
.This is an optional argument, however it advisable to use this argument or else it will give 0
- [value_if_false]: 3rd Argument here we need to select any cell or update the value which we want to show if the logical test in 1^{st} argument result is FALSE. This is an optional argument, however it advisable to use this argument or else it will give 0.
Below are the Logical operators we can use in a logical test
Syntax: IF(logical_test,[value_if_true],[value_if_false])
Logical Operator | Name | How to use | Formula used | Result |
= | Equal to | I want check 1=3 | =IF(1=3,”Correct”,”Incorrect”) | Incorrect |
> | Greater than | I want check 1>3 | =IF(1>3,”Correct”,”Incorrect”) | Incorrect |
>= | Greater than or Equal to | I want check 1>=3 | =IF(1>=3,”Correct”,”Incorrect”) | Incorrect |
< | Less than | I want check 1<3 | =IF(1<=3,”Correct”,”Incorrect”) | Correct |
<= | Less than or Equal to | I want check 1<=3 | =IF(1<=3,”Correct”,”Incorrect”) | Correct |
<> | Not Equal to | I want check 1<>3 | =IF(1<>3,”Correct”,”Incorrect”) | Correct |
Explanation Excel IF Condition Function Examples
Example 1 We want to see the result as “Pass” if marks > 35 or else “Fail”
The Formula used in cell G11=IF(F11>35,”Pass”,”Fail”)
Result Fail
Example 2 We want to see the result as “Pass” if marks >= 35 or else “Fail”
The Formula used in cell G27=IF(F27>=35,”Pass”,”Fail”)
The Result Pass
Example 3 IF Total sales >=$1,000 then eigible for 15% comission or else 5% commission
The formula used in cell G47=IF(F47>=1000,15%*F47,5%*F47)
The Result is $225.00
Excel Nested IF condition
Nested if condition means we can write multiple IF conditions within one if condition.
See below example of nested IF condition.
- Here we need to allocate grades to students as per the marks range.
- If a student gets 175-200 marks he/she should fall in Grade A
- If a student gets 150-174 marks he/she should fall in Grade B
- If a student gets Less than 150 he/she treated as Fail.
Formula used in cell G68 =IF(F68>=150,IF(F68>=175,”Grade A”,”Grade B”),”Fail”)
Result Grade B
Step1: Firstly we are checking whether the student is Pass or Fail it means >= 150 or not.
Step2: If a student gets >= 150 then we want to check whether if it is >= 175 or not to allocate the grades if the student gets less than 150 he/she is Fail.
Step3: If a student gets >= 175 then we will allocate Grade A or else Grade B
Difference between Excel IF condition vs Nested IF Condition
In Excel IF condition, we will write only one logical test under NESTED IF we will write multiple logical tests.