If Statement, if statements are the most commonly used statements in every other programming language. You can also use the IF and Nested IF statements in Google Sheets. The IF and Nested IF features in Google Sheets are very useful for making calculations and performing logical analytical operations in any cell or range of cells. When we have to insert a function when a condition is true and then insert another function inside a function, we use IF and Nested IF statements. The use of these types of statements makes it easier to do various types of calculations in Google Sheets. If and Nested If statements allow you to insert condition-based multiple different types of functions into a cell. When we do logical calculations or we want to run TRUE or FALSE then we use IF statements. If statements are conditional statements, they will only execute when the condition within a cell or range of cells is true. We can combine if statements with logical operations like AND and OR, and Nested if statements
Using IF Statements
If statements can be used in performing simple operations in a single cell, and when we see multiple if statements in any single cell then it becomes Nested If. To use Nested If you first have to know the working of IF statements. Here is how IF statements work.
For using if statements you first have to open Google Sheets, then select the sheet in which you want to use If statements.
The SYNTAX for If statements is as follows:-
=IF(logical_expression, value_if_true, value_if_false)
The following arguments are used in the IF statements:-
- Logical_expression: It is a conditional statement that uses logical operations like <, >, or =.
- Value_if_true: This is the output when the condition is satisfied.
- Value_if_false: Enter the expression that you want when the condition becomes false.
When you replace Logical_expression with your condition, Value_if_true with the value or string you want to display when the condition is satisfied, and Value_if_false with the value or string you want when the condition remains unsatisfied. Keep this in mind when you insert any string in the formula type it with the quotes. When you leave the place of Value_if_true and Value_if_false empty then it will automatically show TRUE or FALSE.
In the above example, we have to check the minimum balance a person should have, so we have used the IF statement here the condition is that the amount should be greater than or equal to 3600, and if this condition is satisfied then it will show “above minimum balance”, if the condition is false then it will display “below minimum balance”.
To apply the same condition in all of the cells just select the cell, then place the cursor over the blue dot at the bottom right corner of the cell. Now, drag the cursor over the required range of cells. Your if statement is now applied in the selected range of cells.
Using Nested IF statements
when we use an IF statement inside the condition of an IF statement then it is called a Nested IF statement.
When doing a complex logical function then we use nested if statements. then it again and again uses conditions to perform a function. you can use multiple nested if together when required. Nested if can be used as many times as you want.
In this example, we have taken a list of people with their balance and to show the statements we have used if statements and nested if statements. which is as follows:-
=IF(B2>=3600,”above minimum balance”,IF(B2<2000,”You will be terminated”,”below minimum balance”))
above is the list and the if statement inserted. Now, to apply the same condition in all of the cells just select the cell, then place the cursor over the blue dot at the bottom right corner of the cell. Now, drag the cursor over the required range of cells. Your if statement is now applied in the selected range of cells.
Here as you can see the nested if statement is applied, As in case of sam you can see that his amount does not satisfy the condition given in list, but now satisfy the condition of nested list so it has shown the statement ” you will be terminated” as given in the nested if statement.
This was all about Nested IF statements in Google Sheets.