Nested If Statements
One of the big problems people have using if statments is they can only set what happens if it is true (i.e. the condition was met, the value in the cell did = 4 ) or false (i.e. the condition was not met, the value in the cell did not = 4). What if you want it to do 3 different things, say one for greater than 4, one for equal to for and one for less than 4? To do this you need to use a nested if statement - this is just an if statement inside an if statement.
Example - There is a number in cell b2
First the simple if statement for match / no match = if (b2=4,"match", "no match)
Now the greater than, less than, match = if (b2>4,"over",if(b2<4,"under","match"))
Note that there is a key difference to these two - the simple one checks if there is a match and reports no match if that isn't the case, the complex one checks if there is no match (if its is over, or under), then reports match if they are't the case. (You might need to re read that)
Lets go through that complex one and see what is doing . There are two if statements in there
= if (b2>4,"over",if(b2<4,"under","match"))
First if statement :
if (b2>4,"over",if(b2<4,"under","match"))
This checks to see if it is greater than 4 (yellow) if the condition is true (it's over 4) then it writes the true statement "over"(green), if it is not over 4 then it moves onto the false statement (pink) This false bit is the second if statement
if(b2<4,"under","match")
This second if statement checks if it is less than 4 (yellow), then it writes the true statement "under" (green) if it is true (less than 4) or the false statement if it is not less than 4 - "match" pink.
To get the outcome match both if statements have to come up false - it was not over 4 and it was not under 4.
The video goes through the process of making a nested if. She makes it quite clear what she is doing and has a similar example to this one
Want to practice? Try to create these 3 nested if statements