Explanation
Use IF function to check whether a certain condition (or conditions) is met.
If the condition is met, the function will return a predefined result.
If the condition is not met, the function will return a different predefined result.
The returned result can be one of the following:
-
-
- Specific text
- Cell/Range reference
- Additional formula – we can actually write another formula within our IF formula. This is called “Nested IF”
-
Click here to go directly to the Excel exercise!
Syntax
The syntax of the IF function is as follows:
=IF(logical test,[value if true],[value if false])
- logical test: This is the condition we would like to check. We can check conditions using various operations, such as equals (“=”), greater than (“>”), smaller than (“<“) or even different (“<>”). So, let’s say we want to check if Cell A2 is greater than cell A1, we will write it this way: A2>A1
- value if true – What the function will return if our condition is met.
- value if false – What the function will return if our condition is not met. If we leave this one empty, we’ll get “FALSE”.
Let’s say we want to check if A2 is greater than A1, and return “A2 is greater” if it’s true, and return “A2 is not greater” if it’s not true. This is what we’ll type:
=IF(A2>A1,”A2 is greater”,”A2 is not greater”)
Practice IF function
Okay, now let’s practice our function.
Grandpa John gives his kids Christmas gifts, but only if they are younger than 18.
Use IF function to check who’s eligible for Christmas gifts this year. Return “Yes” if he’s eligible, and “No” if he is not.
Looking for additional IF exercises? Click here to visit our Exercises section!