How to Use IF Function in Google Sheets
In this article, you will learn how to use IF formula in Google Sheets.
IF function is beneficial when you want to check whether a cell meets a criterion or not and show a number or text as a response.
How to use IF formula in Google Sheets
- Type “=IF(” or go to “Insert” ➝ ”Function” ➝ ”Logical” ➝ ”IF”
- Input a logical test for information to test two returns, one when the data meets the criterion, and the other for the case it doesn’t.
The generic formula is as follows:
Logical_expression: You need to enter the information you want to test and a criterion of the test here. The information and the criterion could be a cell reference, formulas including a series of calculations or manual input. They should be connected by either sign of “equal to”, “greater than”, “less than,” or a combination of them.
Value_if _true: The figure which is returned in a cell when the logical test is successful.
Value_if_false: The figure which is returned in a cell when the logical test is unsuccessful.
The following examples from Simple Example 1 to 6 show typical patterns of how to use the IF formula.
Simple Example 1
Each formula is completed in a cell because all information in each formula is entered manually. Here, we are checking if the number X is equal to 15 or not. The formula returns “OK” in case X is 15 and “ERROR” if not.
Simple Example 2
We check whether values in cell F3 and F4 are equal to 15 or not.
Simple Example 3
We see whether values in cell F3 and F4 are less than 15 or not.
Simple Example 4
You can apply this formula to a list of texts, too. The formula returns “OK” when it finds “Apple”, and ”ERROR” if other cases.
Simple Example 5
In this example, you can see if the date input is equal to 5/4/2022 (May 4, 2022) or not.
Simple Example 6
You test whether each date given is equal to or less than 5/4/2022 (May 4, 2022) or not.
The following screenshot contains a bit more complicated examples. Imagine you are a manager of a sales team and trying to evaluate the performance of each team member based on some criteria.
The first table summarizes the performance of team members, the second one shows the conditions you want to apply for the evaluation, and the third one presents the results of tests done by IF formulas. Let’s see how the IF formula for each condition works.
The Performance of Sales Team table is the table with inputs where you can see different salespeople with their Contract Date, Product Type, and Sales Amount in dollars.
The second table, Performance Evaluation Criteria, summarizes the standards applied to each catergory (Contract Date, Product Type, and Sales Amount) and corresponding evaluations (e.g., On Track and Delay for Contract Date).
Now, let’s have a look at the third table Performance Evaluation table.
Contract Date
The logical test is that if a tested Contract Date is earlier than or equal to 8/31/2022 (August 31, 2022), the formula returns “On Track” and if not, it gives you “Delay”.
Product Type
When a selected product type is “10X”, the function shows “Very Good”, and otherwise, the formula presents “Good”.
Sales Amount ($)
If a chosen sale amount is equal to or greater than 500, the formula returns “Very Good”, and otherwise, it returns “Good”.
The fourth table Formula used for Evaluation shows formulas inserted in the third table. We surrounded three pairs of a formula and the cell containing the fucntions in different colors. All formulas contain only cell references in these examples.
Referencing cells in formulas makes your work much more efficient and accurate because you can change each criterion later and refresh all formulas simultaneously.
For instance, in the picture, if you vary a condition for the evaluation of sales amount from 500 to 750 at cell G27, it is immediately and automatically reflected in the formulas, and only Person C can get the assessment of “Very Good”.
How do you add multiple conditions in IF statement Google Sheets?
When you want to check whether a cell matches multiple criteria, you should use the IFS formula or a combination of IF and AND formulas.
Check this article to learn how to use the IFS function: How to Use IFS function in Google Sheets.