Table of Contents
- STANDARD IF FUNCTION USAGE
- WHAT IS NESTING A FUNCTION?
- HOW TO NEST IF FUNCTION?
- EXAMPLE 1: CHECK IF CELL H10 CONTAINS 1 , 2 OR 3 AND DISPLAY ONE, TWO OR THREE IN CELL I10
A few functions are used extensively when we work in any spreadsheet application like Excel or google Sheets.
Of these functions, IF function is the one which we need to use over and over again to put conditions to our data. But what if we need to apply multiple conditions?
Well, in that case, we can nest our functions to get the double or triple conditions handling.
IF FUNCTION is one of the very important functions and allows us to make the choices.
In this article, we’ll learn how to use NESTED IF in GOOGLE SHEETS.
STANDARD IF FUNCTION USAGE
IF FUNCTION in Google Sheets can be used quite easily.
IF FUNCTION IS USED TO DECIDE THE OUTCOME ON THE BASIS OF A GIVEN CONDITION.
We can use IF FUNCTION in the following way.
=IF(CONDITION CHECK, VALUE/RESULT IF THE CONDITION IS TRUE, VALUE/RESULT IF THE CONDITION IS FALSE)
For example, if we want to check if the value contained in cell A1 is greater than 10 or not; we’ll make use of the following formula.
If A1=5, the result will be FALSE.
If A1=15, the result will be TRUE.
We can also display any other values in place of TRUE or FALSE.
For example, if we want to display “Yes” in place of TRUE and “No” in place of FALSE, the formula will become
This is the way to use IF FUNCTION in Google Sheets.
WHAT IS NESTING A FUNCTION?
When we use a function within a function, it is known as NESTING A FUNCTION.
In the previous section, we learnt the way to use IF FUNCTION in the standard way. You must have noticed that we can put only one condition using the standard IF FUNCTION.
What if we want to use two conditions and display or find out the different outcomes of the three conditions?
In such cases, we need to nest a function.
HOW TO NEST IF FUNCTION?
We can nest a function using the following way.
=IF( FIRST CONDITION, Value/Result if the first condition is true, IF( SECOND CONDITION, Value if the Second condition is True, Value if Second condition is false/ Value if third or remaining condition is true))
The above shown generalized formula is used to test three different conditions using the NESTED IF function.
EXAMPLE 1: CHECK IF CELL H10 CONTAINS 1 , 2 OR 3 AND DISPLAY ONE, TWO OR THREE IN CELL I10
This kind of cases can’t be dealt easily in Google Sheets but we can make use of nested functions to get the things done.
Let us try to solve the given situations using Nested IF.
In this example, we need to deal with 3 different conditions for which we’ll be needing to use the nested if function in Google Sheets.
Enter the following formula in cell I10.
=IF(H10=1,”ONE”,IF(H10=2,”TWO”,”THREE”)) as shown in the picture below.
This formula compares the first condition as H10=1 and put the result as ONE if this condition is true else it’ll go to step 2 where it finds the nested if function which again checks if H10=2 and results in TWO.
If H10 is not equal to 2, the control goes to the next step and shows the result as THREE.
Let us try the solution.
The following animated picture shows the usage of the said example.
The picture above shows the usage of the formula.
When we enter 1,2 or 3 in cell H10, the text ONE, TWO or THREE appears in cell I10 as we intended.