In this tutorial, we will learn how can we use IF condition in excel. IF function is one of the logical functions in MS Excel. This function returns the result either True or False based on a condition. MS Excel 2021 is used.
IF function can be used in many ways. For this tutorial, we will learn how can we use this function to determine if a student has passed or failed. If a student has marks below 50, the condition will be true and the student will be considered as “Fail”, otherwise the student will be considered “Pass”.
This is the data we will be using.
We want the Result output in the Result column. To do that, formula for the IF function should be entered in the Result column.
Syntax of IF function
IF(logical condition, [value if the result is true], [value if the result is false]).
The IF function has three parts:
- Condition: The part where a condition is defined, for example: A number may be compared to another number to see if it is smaller than it or not.
- Result if the value is true: This value will be assigned to the cell in case the condition is true.
- Result if the value is false: This value will be assigned to the cell in case the condition is false.
Using IF function
To write a function or formula, we first need to put “=” sign, then write “IF”.
The condition will be applied to the Marks in column “B”,in the Result column, after typing
IF(, click the cell that contains the marks of the students, since we want this number to be checked if it is less than 50.
<50, to check if the number is smaller than 50, put comma
, , type
"Fail", for if the condition is true and the student has failed, put comma again, and type
"Pass" if the condition is not true. Finally press Enter
It can be seen that it returns the value based on marks of the student.
To apply it to the whole column, select the cell, drag the bottom right corner of the cell downwards along the column.
The final result will look similar to this.