The IF Function is one of the most valuable functions in spreadsheets. However, many new spreadsheet users avoid using the function, fearing its potential complexity. This article will debunk that belief and help you learn how to use the IF function with simple examples.
What Is the IF Function?
The IF function is a logical expression that evaluates simple conditions and returns a different value if the condition has been met or not.
When using the IF function, you need to supply a condition (IF) and the expected inputs.
How the IF Function Works
The IF function makes a comparison between the condition you have set and another value. Say you run a bookstore, and you want to have a warning whenever a book’s inventory is below five books. Your condition, therefore, is that the number of books must be greater than 5.
After establishing your condition, you must specify the return parameters if the condition is met (true) or not (false).
Still using the book store owner example, if the books are less than five, you might want the function to return a warning like “ORDER NOW!”. If not, you can give the process a parameter like “ALL WELL” or leave the parameter blank.
Example
Syntax: IF(logical_expression, value_if_true, value_if_false)
Condition: The number of books should be greater than 5.
Comparison: The function will compare the number of books remaining in the store inventory with 5. The comparison will form the logical_expression in the syntax.
- For the book “Meet Danny,” we have 4 books remaining in cell C2
- C2 >5 is the statement that compares whether the “Meet Danny” books are more or less than 5
Return Values: You will give the IF function two return values. The function returns the first value if the condition is true (value_if_true in the syntax). Else it will return the second value if the condition is false (value_if_false in the syntax).
In our example;
- The first value is “ALL WELL”
- The second value is “ORDER NOW.”
So the final syntax we would use is =IF(C2>5,”ALL WELL” , ”ORDER NOW”)
Output
The IF function returns “ORDER NOW”; for this formula so that means that cell C2 did not meet our condition of having a value greater than 5.
To apply the function to the other cells in column C, click the small blue box at cell D2 (pointed by the arrow above) and drag it down through the cells whose value you want to be displayed. The result will be as follows.
Types of Comparisons
The following are the different types of comparisons you may use:
> greater than
< less than
>= greater than or equal to
<= less than or equal to
= equal to
<> not equal to
You should use the most appropriate comparison to meet your condition. For the example above, you can still use (<) less than to achieve the same results by changing the values as shown below.
Return Values
If you want the IF function to return a text value, you need to enclose it in double-quotes (“ ”), but you should not have it in double-quotes if you want to return a numerical value.
In the book store example, let us replace the second value “ALL WELL” with the number 0.
As you can see in the example, the numerical value 0 has no quotation marks and reads as follows;
=IF(C2<5, “ORDER NOW” , 0)
The return value can also be a mathematical expression such as a SUM, ADD, etc.
Say you want to double the number of books that have “ORDER NOW”; the result is below.
We have used <> (not equal to) for this comparison
IF (B2 <>0, A2 * 2, A2)
If the value in B2 is not equal to 0 (zero), then the output value will be the multiplication of the number of books and two.
Otherwise, the output value will be the same as the value in A2. 0 in this case.
The Bottom Line
The IF function is versatile, and this article is yet to exhaust all its capabilities. But, you now have the basics you need to start using it confidently. Once you can handle these simple examples, head over to Productivity Spot to learn more about how to use the IF function in Google Sheets.






Comments