Related Function:

The IF function returns one value if a condition you specify evaluates to TRUE, and another value if that condition evaluates to FALSE.

Syntax

=IF(logical_test,[value_if_true],[value_if_false])

Note: Up to 64 IF functions can be nested as value_if_true and value_if_false arguments to construct more elaborate tests.

  • If any of the arguments to IF are arrays, every element of the array is evaluated when the IF statement is carried out.
  • To test many conditions, consider using the LOOKUP, VLOOKUP, HLOOKUP, or CHOOSE functions.

Arguments

Argument Description
logical_test Any value or expression that can be evaluated to TRUE or FALSE
[value_if_true] Optional. The value that you want to be returned if the logical_test argument evaluates to TRUE

   If logical_test evaluates to TRUE and the value_if_true argument is omitted, i.e. there is only a comma following the logical_test argument, the IF function returns 0 (zero)
[value_if_false] Optional. The value that you want to be returned if the logical_test argument evaluates to FALSE

  If logical_test evaluates to FALSE and the value_if_false argument is omitted, i.e. there is no comma following the value_if_true argument, the IF function returns the logical value FALSE. 
  If logical_test evaluates to FALSE and the value of the value_if_false argument is blank, i.e. there is only a comma following the value_if_true argument, the IF function returns the value 0 (zero)

Examples

  A B C D
1 Actual Expense Predicted Expense    
2 $2,500.00 $1,200.00    
3 $800.00 $900.00    
4 $1,200.00 $1,500.00    
5        
6 Formula Result Notes
7 =IF(A2>B2,”Over Budget”,”OK”) Over Budget Because the actual expense of $2500 (A2) exceeded the predicted expense of $1200 (B2), the result is Over Budget
8 =IF(A2<B2,TRUE,IF(A3>B3,”Over Budget”,”OK”)) OK The first IF function is FALSE. Therefore, the second IF statement is calculated and because it too is FALSE, the result is OK
9 =IF(A4=1200,B4-A4,””) 300 Because A4 equals 1200, the Actual Expense $1200 is subtracted from Predicted Expense $1500 to tell you how much over budget you are. The result is 300. If A4 didn’t equal 1200, then empty text (“”) would be returned
10 =IF(A2<B2,TRUE,IF(A3>B3,”Over Budget”,”OK”)) OK The first IF function is FALSE. Therefore, the second IF statement is calculated and because it too is FALSE, the result is OK