Ready to learn about the IF function in Google Sheets? You’re in the right spot. Our IF function Google Sheets guide shows you how to break down the formula – and the best ways to troubleshoot potential issues. Let’s get started!
What Is an IF Function?
The IF function is a conditional test, comparison, or function that lets you test whether a condition is true or false. It then returns a value or performs an action based on the result. You can think of an ‘IF’ function in Google Sheets as a decision-maker.
An Example of IF Function
You’ll use IF function to evaluate a specific condition, such as, “Is the light green?” If the condition holds true, it directs the program down one path (e.g., “Go forward.”). On the other hand, if the condition is false, it steers the program down a different path (e.g., “Stop and wait.’’).
Essentially, IF functions empower the computer to adapt its actions based on the circumstances at hand.
This Article Covers:
Syntax of the IF Function Google Sheets
IF(logical_expression, value_if_true, value_if_false)
- Logical_expression: This is the condition that you check in the function. It is an expression or reference to a cell containing an expression that would return a logical value (i.e., TRUE, FALSE).
- Value_if_true: The value the function returns if logical_expression is TRUE.
- Value_if_false: (optional argument) The value the function returns if logical_expression is FALSE. If you don’t specify the value_if_false argument and the checked condition is not met, the function will return FALSE.
Now let’s look at some examples to understand how to use the IF function in Google Sheets in real-life scenarios.
Example 1: Checking a Single Condition With IF Function
Suppose you have students’ exam marks and want to specify whether a student has passed or failed (as shown below):
Using the IF function in Google Sheets, the “pass/fail” formula would be:
=IF(B2>35,"Pass","Fail")
Step 1: Select an empty cell to perform the calculation.
Step 2: Type =IF( into the cell or select it from the formula suggestions.
Step 3: Select the cell you want to reference.
Step 4: Type in the logical expression or condition you want. In our case, it’s >35.
Step 5: Add a comma and type the text you want to return for “value if true” and “value if false.” Enclose them in quotation marks.
Step 6: Press Enter. If the score exceeds 35, it will return a “Pass.” Otherwise, it will return a “Fail.”
Note: You may see a suggestion for autofill. You can click the tickbox to do so.
Example 2: Using IF Functions with “Greater Than”
You can use the IF function with the “greater than” operator. In our example spreadsheet, we can find values greater than 70 and give them an A.
Step 1: Select an empty cell to perform the calculation.
Step 2: Type =IF( into the cell or select it from the formula suggestions.
Step 3: Select the cell to reference.
Step 4: Type in the logical expression or condition you want. In our case, that is <70
Step 5: Add a comma and type “A” to return an A grade.
Step 6:You can add an empty space for “value if false” to leave the rest of the cells blank.
Step 7: Press Enter and copy the formula to the rest of the cells.
Note: Our formula will return an “A” if the score exceeds 70. Otherwise, it will leave a blank space.
Example 3: Using IF function with “Equal to”
You can use the IF function with the equal to the operator as well. For example, in our sample spreadsheet, we can find the values equal to 90 and grade it A+.
We’ll use the formula:
=IF(B2=90,"A+"," ")
We can use a blank space for value_if_false to leave the rest of the cells blank.
If we copy the formula to the other rows, any score with 90 will be graded A+.
Related reading: How to Sort Data in Google Sheets
Example 4: Checking Multiple Conditions with the IF Function
What if you have a grading system and you have to assign a grade to a student, based on their composite marks?
In this case, you’ll need to check whether the marks are above 35, as well as the range in which it lies. The formula that will give you the result in this case:
=IF(B2<35,"F",If(B2<50,"D",If(B2<70,"C",If(B2<90,"B","A"))))
This formula first checks whether the score is less than 35. If it is, it returns F. Otherwise, it moves on to the next condition (and so on).
Example 5: Calculating Commissions Using IF Function in Google Sheets
Google Sheets; If Function allows you to perform calculations in the value section. For example, you might use the IF function to calculate the sales commission for each sales representative.
Say that a sales rep gets zero commission for sales under $50,000, a 4% commission if the sales are between $50-80,000, and a 10% commission if the sales are $80,000 and greater.
Here is the formula used:
=IF(B2<50,0,IF(B2<80,B2*4%,B2*10%))
Step 1: Type =IF( into the cell. You can also select it from the formula suggestions.
Step 2: Type the first condition, which is B2>50. Add a 0, so if the value is less than 50 – the sales reps will receive zero commission.
Step 3: Type the second IF statement: B2<80
Step 4: Click Enter and copy the formula to the rest of the rows.
In the example above, the calculation is done within the IF function. When the sales value is between 50-100K, it will return B2*4% (meaning that the 4% commission is based on the sales value).
Example 6: Using AND/OR Operators in IF Function
Within the IF function, you can use the AND/OR comparison operators to check multiple conditions simultaneously.
Suppose you have a list of students’ marks and attendance. Students only receive a scholarship if they score 80+ and have an attendance of more than 80%. You can quickly identify such students using the AND condition within the IF function.
Here is the formula to identify the students’ scholarship eligibility:
=IF(AND(B2>80,C2>80%),"Yes",”No”)
This formula will check both conditions in the AND function. If the AND function returns TRUE, the IF function returns “Yes.” Otherwise, it will return “No.”
Frequently Asked Questions
How Do You Write an IF Function in Google Sheets?
The syntax for the IF function is:
IF(logical_expression, value_if_true, value_if_false)
Can You Do Multiple IF Statements in Google Sheets?
You can use multiple IF statements nested inside each other. However, an easier way would be to use the IF function, which allows multiple arguments simultaneously – for multiple conditions:
=IF(B2<35,”F”,If(B2<50,”D”,If(B2<70,”C”,If(B2<90,”B”,”A”))))
Can You Put a Formula in an IF Function?
You can use any formula or logical expression as the “logical expression” argument of the IF function. For example, you could use a formula that calculates a sum or average. You could also include a logical expression that checks whether a cell contains a certain value.
What Is an Example of an IF Statement?
An example of an IF statement is a pass/fail formula:
=IF(A2>40,"Pass","Fail")
If the value in cell A2 is less than 40, the formula will return the word “Fail.” If it’s more than 40, the formula will return “Pass.”
Wrapping Up
Now that you’ve read through our easy IF Function Google Sheets guide, we hope you have a better grasp on this concept! Thinking of improving your Google Sheets expertise even more? There’s never been a better time to get ahead of the curve with Udemy’s range of courses!
Also, be sure to check out the following Google Sheets functions tutorials:
9 thoughts on “The Easiest IF Function Google Sheets Guide”
I need help!!
I am trying to make a function that says: if A7 = “yes” AND A4<A5 then I want the cell to say "sell shares"
right now I am using: =IF(A7="yes",A4<A5,"sell shares") it is just showing up as "TRUE"
I might be talking crap, but what about this?
=IF(AND(A7=”YES”,D4<E4),"Sell Shares","")
Just be carefull when you drag the formula down, it will also change the A7 to A8, if you don’t want that you should manually change it back to A7
Or add $ to the row number to get it to stay.
Learning something new every day 😀
Hi Jean!
I have a list of all countries in one column, and I have a shorter list showing only countries that are eligible for a specific Shipping service.
Can I create an if function that gives the response to “If this country is part of the dedicated line service, say yes, if not, say no”
I tried but ran into value problems
If this cell (a cell in the ALL country column) shows in this column (list of all countries that are eligible) say YES .. otherwise say NO
Hope that makes sense! 🙂
– Omar
Can you include commands in IF statements?
Good Afternoon
thnx for your great efforts
i need your help in one thing if you please
for example :
i have Cells in column (A) with multiple choices in a drop down list .. on of these choices is ( NOT requested )
i want to make Cells in column (B) becomes black only when i choose the ( NOT requested )
thnx in advance for your help
You can do this with Conditional Formatting ( in the Format Menu). Apply the formatting to Column B and enter a Custom Formula
=$A1 = “NOT Requested”
and set the background for black for the conditional formatting.
Since the text you want to use to trigger the format change is in a different cell, you have to use a Custom Formula. If the text was in Column B, you could just use the Text Equal To condition.
Hope this helps
Comments are closed.