The Google Sheets IF function is a built-in logical function. We use the IF function when you want to check for a condition, then return a result if the condition is TRUE or return a different value if the condition is FALSE.
Google Sheets IF Function Syntax
The syntax for the IF Function is as follows:
IF(logical_expression, value_if_true, value_if_false)
- logical_expression – The condition or test you check in the function that returns a logical value, i.e. TRUE or FALSE.
- value_if_true – The value the function returns if logical_expression is TRUE.
- value_if_false – [ OPTIONAL ARGUMENT that is blank by default ] – The value the function returns if logical_expression is FALSE.
Pro Tip: Order matters. If you aren’t getting the value you expected then check to see that you are passing the value_if_true and value_if_false in the correct order.
See below for some examples using the IF function:
1. Google Sheets IF Cell Is Greater Than
A very common use of the IF function is just to check if a cell contains a value greater than another value. In the following example, if a cell contains a value greater than 90, then return the value 1, if not then return 0.
2. Google Sheets IF Cell Contains Text Then Return A Value:
In the following example, a combination of the IF and ISTEXT functions to check if a cell contains text. If it does, then return the value 1 if not then return 0.
3. Google Sheets IF Value Between Two Numbers:
In this example, use the combination of the IF and AND functions to check for multiple conditions. If the cell is greater than 50 and less than 75 then return 1 else return 0.
4. Google Sheets IF Empty
Use IF along with ISBLANK to check if a cell is empty or not. The following functions return 1 if a cell is blank and 0 if it is not.
The Google Sheets IF function has foundations from conditional statements in computer programming. Check out this Wikipedia article on conditional theory if you want a deeper understanding.