In this tutorial, you will learn how to do if then in Google Sheets.
How To Do If Then In Google Sheets
When you’re working on complex spreadsheets, you might find yourself creating similar sets of calculations for different scenarios, but fortunately Google Sheets has powerful tools to help eliminate this extra work.
Any time you want to modify a Google Sheet when certain criteria are met, you can use If/Then statements to switch between the different options.
If/Then statements can save a lot of time switching adjusting your spreadsheet every time something changes.
Read on to learn how to start using the power of If/Then statements in your spreadsheets
Basic IF Formula
When we talk about If/Then statements in Google Sheets, we’re talking about the IF() function, which outputs different values based on the results of a logical test.
If the logical test is TRUE, the first output is used. If it’s FALSE, the second output is used.
Let’s look at this in action:
Select the cell you want to the If/Then statement in and type the following: “=IF(A1=B1, “They Match!”, “They Don’t Match”)”. Hit enter.
In the above formula, we’re using the IF function which takes three parameters inside the parentheses, separated by commas.
The first parameter is a logical test, in this case “A1=B1”, which checks if the values stored in cells A1 and B1 are equal.
If they are, this expression evaluates to TRUE, if not it evaluates to FALSE.
When the logical test is TRUE, the IF function outputs the second parameter: “They Match!”.
When the logical test is FALSE, the last parameter is output: “They Don’t Match”
Now when the spreadsheet changes, the IF statement will check if the logical expression is true and display results accordingly
Other Logical Tests
In the example above, we used an equals sign to check if two values are equal, but you can also do a number of other tests to specify which of the outputs the IF statement should return.
Here are a few of them:
- Greater than (>) – evaluates as TRUE if the first value is greater than the second
- Less than (<) – evaluates as TRUE if the first value is less than the second
- Not equal to (!=) – evaluates as TRUE whenever the two values do not match
- ISBLANK(A1) – replace the A1 with reference to the cell you want to check. Evaluates as TRUE if the cell is blank
Using IF In Nested Formulas
While the IF formula is extremely powerful on it’s own, it becomes even more powerful when combined with other functions.
In the example above, the second and third parameters were both simple text strings.
However, each of these could also be a separate formula.
For example, this If/Then statement that calculates either the Min or Max based on the option selected by the user in Cell A6:
=IF(A6="Find Min", MIN(F7:F11), MAX(F7:F11))
Example Spreadsheet: Make a copy of the example spreadsheet
In this tutorial, I covered how to do if then in Google Sheets. Want more? Check out all the Google Sheets Tutorials.