How to Use The If Function In Google Sheets

How to Use The If Function In Google Sheets
Reading Time: 4 minutes

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.

Syntax

IF(logical_expression, value_if_true, value_if_false)

  • logical_expression – An expression representing some logical value, i.e. TRUE or FALSE. Here, 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.

Sample Examples

=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”)

=IF(TRUE,4,5)

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.
Figure 1: Dataset of interest
Figure 1: Dataset of interest

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.

=IF(B2>C2,”Yes”,”No”)

Figure 2: Example of checking a single condition with IF Function in Google Sheets
Figure 2: Example of checking a single condition with IF Function in Google Sheets

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:
Figure 3: Example of IF Function in Google Sheets
Figure 3: Example of IF Function in Google Sheets

Checking Multiple Conditions With If Function (Nested IF)

The syntax of the nested IF in Google Sheets is as follows:

=IF(first_statement,value_if_true,IF(second_statement,value_if_true,value_if_false))

  • 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:

% RangeGrade
>90A
75-90B
60-75C
40-60D
<40F
  • In this case, you can use the nested if statements. Let’s say you have students mapped against their marks, as shown below:
Figure 4: Dataset of interest
Figure 4: Dataset of interest
  • Select a cell in the Grade Column and use the formula:

=IF(B2<40,”F”,If(B2<60,”D”,If(B2<75,”C”,If(B2<90,”B”,”A”))))

  • 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.
Figure 5: Example of Checking Multiple Conditions With If Function in Google Sheets
Figure 5: Example of Checking Multiple Conditions With If Function in Google Sheets

Conclusion

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.

See Also

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.

One response to “How to Use The If Function In Google Sheets”

Leave a Reply