IF(logical_expression, value_if_true, value_if_false)One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.
logical_expression:
The condition that you want to evaluate. This can be a comparison between values, a function that returns TRUE or FALSE, or any expression that results in a boolean value.
value_if_true:
The value or expression that will be returned if the logical_expression evaluates to TRUE. This can be a number, text, formula, or cell reference.
value_if_false:
The value or expression that will be returned if the logical_expression evaluates to FALSE. This can also be a number, text, formula, or cell reference.
The IF function in Google Sheets is a fundamental tool used to perform logical tests and return specific values based on whether the test evaluates to true or false. It allows users to create conditional statements that can help in decision-making processes within their spreadsheets. The IF function is particularly useful for categorizing data, performing calculations based on conditions, and automating responses based on user input.
In simpler terms, the IF function lets you check a condition and return different results depending on whether that condition is met.
Imagine you are managing a student grading system and want to determine whether each student has passed or failed based on their scores.
| StudentID | StudentName | Score |
|---|---|---|
| 1 | Alice | 85 |
| 2 | Bob | 45 |
| 3 | Charlie | 78 |
You want to create a new column that indicates whether each student has "Passed" or "Failed" based on a passing score of 50.
To achieve this, you would use the IF function as follows:
=IF(C2 >= 50, "Passed", "Failed")In this formula:
C2 is the cell containing the Score for the student.50 is the threshold score for passing."Passed" is the value that will be returned if the score is greater than or equal to 50."Failed" is the value that will be returned if the score is less than 50.When you apply the IF formula to the Student Scores Table, the output would look like this:
| StudentID | StudentName | Score | Result |
|---|---|---|---|
| 1 | Alice | 85 | Passed |
| 2 | Bob | 45 | Failed |
| 3 | Charlie | 78 | Passed |
In this case, Alice and Charlie have passed, while Bob has failed.
The IF function is beneficial because it allows for dynamic decision-making within your spreadsheets. It simplifies the process of categorizing data and automating responses based on specific criteria. Additionally, it can be nested with other functions to create more complex logical tests, making it a versatile tool for data analysis.
The IF function is an essential tool for anyone working with data in Google Sheets, providing a straightforward way to enhance data analysis and reporting capabilities.
Happy spreadsheeting!
You have a sales report where Column A lists product IDs and Column B lists sales figures. Use the IF formula to flag any sales below a certain threshold, marking them as "Underperforming" or "Meets Expectations," streamlining performance reviews.
Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.
Browse our complete library of Google Sheets formula guides
Compare your options
Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.
AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.