Logical function
Logical function
Logical Functions
Learn how to use Excel's logical functions such as the IF, AND and OR function.
If Function
The IF function checks whether a condition is met, and returns one value if
TRUE and another value if FALSE.
1. Select cell C2 and enter the following function.
img1
The IF function returns Correct because the value in cell A1 is higher than 10.
And Function
The AND Function returns TRUE if all conditions are true and returns FALSE if
any of the conditions are false.
1. Select cell D2 and enter the following formula.
img2
The AND function returns FALSE because the value in cell B2 is not higher than
5. As a result the IF function returns Incorrect.
Or Function
The OR function returns TRUE if any of the conditions are TRUE and returns
FALSE if all conditions are false.
1. Select cell E2 and enter the following formula.
img3
The OR function returns TRUE because the value in cell A1 is higher than 10. As
a result the IF function returns Correct.
General note: the AND and OR function can check up to 255 conditions.
2. Nested If
The IF function in Excel can be nested, When you have multiple conditions to
meet. The FALSE value is being replaced by another If function to make a
further test. For example, look at the formula below.
1a. if cell A1 equals 1, the function returns bad.
img4
1b. if cell A1 equals 2, the function returns good.
img5
1c. if cell A1 equals 3, the function returns Excellent.
img6
1d. if cell A1 equals another value, the function returns No Valid Score.
img7
img8
2b. If cell A1 is greater than 10 and less or equal to 20, the function returns
700.
img9
img10
2c. If cell A1 is greater than 20 and less or equal to 30, the function returns
1400.
img11
2d. If cell A1 is greater than 30, the function returns 2000.
img12