Filed under: AND, Excel, Excel Formulas, Formula, Formula Syntax, IF, Nest, Nested, OR, String, Syntax [Edit Tags]
"Nested" IF Statements
At times you may find it necessary to use multiple or "Nested" IF statements in a formula.
We know that the syntax for an IF statement is:
=IF(VariableA=Value,TRUE,FALSE)
Within an IF statement an additional "Nested" IF statement can be added. You will see this quite often within Microvellum.
Examples of "Nested" IF statement syntax:
Example A =IF(VariableA=Value,IF(VariableB=Value,TRUE,FALSE),FALSE)
Example B =IF(VariableA=Value,TRUE,IF(VariableB=Value,TRUE,FALSE))
Example A is showing the "Nested" IF statement as the TRUE value. Example B is showing the "Nested" IF statement as the FALSE value.
In either example the "Nested" IF statement only evaluates when the preceeding statement evaluates to use that portion of the formula.
Let's breakdown the above Example A. If VariableA is TRUE, then the TRUE value is returned. The TRUE value in this case is another formula. So, this "Nested" statement is only evaluated when the prior variable (VariableA) is TRUE. In Example B the "Nested" statement is only used when the prior statement is FALSE. When this "Nested" IF statement is evaluated, the end Value (TRUE or FALSE) is returned for that portion of the formula.
"Nested" IF Statements can be strung together to return an end Value.
Example C =IF(VariableA=Value,TRUE,IF(VariableB=Value,TRUE,IF(VariableC=Value,TRUE,IF(VariableD=Value,TRUE,FALSE))))
This is only one example of how you can string "Nested" IF statements together. There are many ways to string formulas together.
NOTE: As soon as a formula evaluates, the remaining part of the formula is no longer used. In the above Example C, if VariableA is TRUE, then the TRUE value of that portion of the statement is the end Value for the entire formula. The rest of the formula will be ignored.
SYNTAX NOTE: Each "Nested" IF statement has it's own set of parenthesis () surrounding it. Notice at the end of the Example C formula there are four parenthasis to end the formula. Each OPEN parenthasis must have and END parenthasis to allow the formula to evaluate. Otherwise you will receive formula syntax errors within Microvellum. Placement of the end parenthasis is important to make sure your formula is evaluating correctly.