What it does – Checks a condition and returns a value specified if true, the other if false.
logical_expression – An expression representing some logical value, i.e. TRUE or FALSE. The expression can refer to a cell containing an expression. The output of this expression should be a logical value, i.e. True or False, Yes or No.
value_if_true – The value that the function returns if logical_expression is TRUE.
value_if_false – [ OPTIONAL – blank by default ] – The value that the function returns if logical_expression is FALSE.
=IF(100>200, "Yes", "No")
//Returns No as the answer since the logical expression is false.
//Returns Yes if the value in cell B2 is greater than that in C2, else it returns No.
What is the IF Function in Google Sheets?
The IF Function in Google Sheets allows you to check a condition and then, based on it, returns a specified value if it’s TRUE, or returns the other specified value if it’s false. Let’s say you want to check whether the value inside a cell is higher than 20 or not. If the value is higher than 20, the output should be. Yes, the value is higher than 20. If the value is lower than 20, then the output should be. No, the value is NOT higher than 20.
You can use the IF Function in Google Sheets to evaluate such results based on the specified condition. You will learn about the IF Function and its variations in this article.
Why use the IF Function in Google Sheets?
The IF Function in Google Sheets allows you to make logical comparisons between a value and what you expect. So, let’s say you want to compare the sales data of individuals against the average sales. If the individual sales data is higher than the average sales, then you want to reward the employee with a performance bonus.
Here, you can see that the condition is whether the individual sales are higher than average sales. If the statement is true, you want to reward the employee with a bonus. If the statement is False, you don’t reward the employee with a bonus. So depending on your use case, you can have different conditions. Accordingly, you can use the IF Function in Google Sheets to make logical comparisons.
=IF(A1 = "Welcome to Amigo","A1 cell contains a string","A1 cell does not contain a string")
=IF(A1,"A1 is TRUE","A1 is false")
How to use the IF Function in Google Sheets
Checking a Single Condition With If Function
Step 1: Select the cell in which the formula will be applied
- Open Google Sheets
- Select the cell in which the formula will be applied.
Step 2: Write the formula using proper syntax
- You want to compare whether the individual sales data are higher or lower than the average.
- If the output is True, the employee is eligible for a bonus.
Step 3: Drag the mouse to apply the formula to relevant cells
- Now drag the selection down to all the cells.
- You can see the final output below:
Checking Multiple Conditions With If Function (Nested IF)
The syntax of the nested IF in Google Sheets is as follows:
- Here, if the output of the logical expression is false, you can apply more conditionals in the value_if_false parameter.
Now, let’s say you want to assign grades to students. The grade brackets are as follows:
- In this case, you can use the nested if statements. Let’s say you have students mapped against their marks, as shown below:
- Select a cell in the Grade Column and use the formula:
- Now drag down the selection to the last student.
- You can see that all the students have been assigned a grade corresponding to their marks.
- Here, if the first condition is True,i.e. Marks are less than 40, then an F grade is assigned. If marks are greater than 40, we go to the next conditional. If the marks are less than 60, a D grade is assigned. If the marks are greater than 60, we go to the next conditional, and so on.
The IF Function in Google Sheets allows you to make logical comparisons between a value and what you expect. You can also check multiple conditions at a time using NESTED IF statements. If you want to know more about the IF Function in Google Sheets, you can go through the official documentation by clicking here.
Want to know more formulas and functions in Google Sheets? Look at our definitive guide on Google Sheets which covers hundreds of such topics here. Enjoy reading!
Conditional Formatting in Google Sheets: Get started with Conditional Formatting in Google Sheets
How to Create a Burndown Chart in Google Sheets: Learn how to create burndown chart in Google Sheets
How to create a Funnel Chart in Google Sheets: Learn how to create funnel charts in Google Sheets.
How to Use the SORTN Function in Google Sheets: Learn how to use the SORTN function in Google Sheets.
Complete Guide on the REGEXEXTRACT Function in Google Sheets for 2022: Learn how to use the REGEXEXTRACT function in Google Sheets and its variations.