Google Sheets is known to be a medium for housing your data. It’s what people use to track their personal finances and even comes in handy for several professional purposes. A rarely used portion of Google Sheets is its extensive list of functions that help us assort our data and derive conclusions from it, much of what is solved by programming. One of the most common features used in every programming language is the IF statement, and that is something that can be replicated with Google Sheets. In this article, we will demonstrate how you can use the IF and Nested IF operators on Google Sheets.
The IF operator is also found in MS Excel and works similarly; you enter the function in a cell and based on certain conditions and receive an output depending on whether or not those conditions are satisfied. When you nest an IF statement, you’re allowed to make more advanced and complex analyses.
Here’s a quick summary of all that we will be covering in this article:
- How to use the IF statement in Google Sheets?
- How to use the nested IF statement in Google Sheets?
- How to highlight a row using conditional formatting?
- How to set up multiple conditional formatting rules in Google Sheets?
How to use the IF statement in Google Sheets?
Before we begin with the process, let me first explain exactly what it is that an IF statement does. Suppose a cell has a value = 200. In some other cells, we apply the IF statement where the value of that cell is dependent upon the value of the cell valued 200. So, if the cell is valued above 100, we may return the value ‘YES’, and ‘NO’ if not. This is what the logical operator looks like:
=IF(logical_expression, value_if_true, value_if_false)
- Logical_expression – This is our condition and can be represented by ‘=’,’<’,’>’
- value_if_true – This is the value that comes out if the logical_expression is true
- value_if_false – This is the value that comes out if the logical_expression is false
So, in our example above, our syntax would be:
Once you’ve typed out the relevant operation statement, press Enter to get the value. Google Sheets’ smart and intuitive UI also provides an Autofill service to make your work easier.
How to use the nested IF statement in Google Sheets?
Nested IF statements may seem a little complicated at first but they’re easy to comprehend since they follow the same principle as an ordinary IF statement. As the name suggests, a nested IF function is where there is an IF function inside an IF function. Let me explain how these work with an example. We’ll enter a nested IF expression that finds the biggest number out of the three, we have manually imputed.
Let me break it down for you (it would be helpful if you could think of it while keeping the IF function template in mind). First is the logical expression, if B2>B3, it checks if it is greater than B4 as well. If it is, it prints that. If B2<B4, we check if B4 is bigger than B3 and print it if that’s true. If B2 isn’t greater than B3, to begin with, we print B3.
Similarly, you can nest as many IF functions into one another as you want, though that would make your function statement unbearably large. Nested IF statements are needless if you want to find the highest value since there are MAX and MIN functions for that, but there are several other professional purposes that it fulfills.
How to highlight a row using conditional formatting?
You can use conditional formatting to highlight a particular set of selected rows and make them distinctive. Here’s how:
- Open Google Sheets and select the rows you want to highlight
- From the option tabs on top, click on Format and further select Conditional Formatting
- From the drop-down that says ‘Format cells if,’ select ‘Custom Formula is’
- In the ‘Value or Formula’ column, enter the formula accordingly and click on Done
How to set up conditional formatting rules in Google Sheets?
Conditional Formatting helps users make a part of their data look different. Google Sheets allows you to take the levels of customization a bit further as you can create your own formatting rules here.
- Click on Format > Conditional Formatting
- From the dialog box to your right, click on Add another rule
- Enter the inputs i.e., cells on which this new rule would apply and the conditions
- Press Done.
We hope that this article was able to make your Google Sheets experience a little easier!