- What If?
- Using More Advanced Conditions
- Nesting IF() Functions
- In Conclusion
Nesting IF() Functions
IF() functions can be nested within each other. That is, one IF() function can be an argument to another IF() function. It would be the true_value or the false_value argument. When you nest IF() functions, the value from the inner function is not displayed but is used as an argument to the outer IF() function. The functions are evaluated from the inside out, and the final display value is determined by the outermost IF() function.
Here’s an example of nesting IF() functions. Suppose that cell B14 contains the current temperature. You want to display "Hot" if the value is greater than 90 degrees, "Cold" if the value is less than 35 degrees, and "Comfy" if the value is in-between. Here’s how to achieve this:
=IF(B14>90,"Hot",IF(B14<35,"Cold","Comfy"))
First, the inner IF() function looks at the value in cell B14 and returns "Cold" if it is less than 35 and "Comfy" otherwise. Then the outer IF() function looks again at the value in B14 and displays "Hot" if the value is greater than 90 and displays whatever the inner IF() function returned otherwise.
For my last example, this nested IF() assigns letter grades based on numerical scores as follows:
91 and above = A
81-90 = B
71-80 = C
61-70 = D
Below 70 = F
=IF(A2>90,"A",IF(A2>80,"B", IF(A2>70,"C",IF(A2>60,"D","F"))))