Syntax: = IF( logical_test, [value_if_true], [value_if_false])
Mastering the IF formula is a key to success in using Microsoft Excel. The formula uses if, then, else logic to evaluate criteria and provide a result based on if the criteria is true or not. In other words: If the condition specified in the logical_test is met the formula will result in what is specified in the [value_if_true] argument, but if the condition is not met then the formula will result in the [value_if_false] argument. Notice how the [value_if_true] and [value_if_false] arguments are encased in brackets—the brackets signify that the argument is optional. In the case of the IF formula, if either or both of these arguments are omitted the formula will either result in TRUE or FALSE. Remember that TRUE or FALSE in Excel evaluates to 1 and 0, respectively.
The function is split into three parts:
- Logical_test. The phrase logical test refers to the evaluation of two items that are either greater than (>), less than (<), equal to (=), or not equal to (< >), etc. For example: A2 > B2, read A2 is greater than B2, is a logical test that will result in either TRUE or FALSE. If A2 is greater than B2 the formula will result in TRUE. If A2 is not greater than B2 the formula will result in FALSE.
- Value_if_true. This is where you can specify what you want the formula to do if the logical_test results in TRUE. This is an optional argument; if omitted the formula will simply display TRUE if the condition is met. This can be text, another formula or a number.
- Value_if_false. This is where you can specify what you want the formula to do if the logical_test results in FALSE. This is an optional argument; if omitted the formula will simply display FALSE if the condition is met. This can be text, another formula or a number.
Example: =IF ( A2 > B2, “the value in A2 is larger than B2” , “the value is A2 is less than or equal to B2”)
Example: =IF ( A5 >= B5, A5, B5)
Example: = IF (A7 = “California”, “West”, “East”)
Click here to open the excel spreadsheet shown below: IF_Formula_Examples
For information on how to use multiple Excel IF statements in the same formula, please visit the advanced Excel Help page: Using Multiple IF Statements