@IF

@IF(condition;x;y) evaluates condition and returns one of two values, depending on the result of the evaluation. If condition is true, @IF returns x; if condition is false, @IF returns y.



Arguments

condition is usually a logical formula, a formula that evaluates a condition as 1 for true or 0 for false. However, you can use any formula, number, text enclosed in " " (quotation marks), or name or address of a cell as condition. Your spreadsheet evaluates any condition that does not equal zero as true and any condition that does equal zero as false. Blank cellstext equal zero when used as condition.

x and y are values, text enclosed in " " (quotation marks), or the addresses or names of cells that contain values or labels.



Notes

@IF is useful when combined with @ERR and @NA to document errors or missing data in formulas. It is also useful in preventing ERR, NA, and calculation errors in situations where data may be missing or inaccurate, for example, to prevent division by zero.

You can nest @IF functions within one another to create a complex condition. For example,

@IF(TOT>10000;TOT*0.15;@IF(TOT>5000;TOT*0.10;TOT*0.02))

nests two @IF functions to determine a commission rate based on three levels of sales: total sales greater than $10,000, total sales greater than $5,000, and total sales less than or equal to $5,000.



Examples

@IF(BALANCE>=0;BALANCE;"Overdrawn") returns the value in the cell named BALANCE when the value in BALANCE is 0 or positive, or returns the label Overdrawn when the value in BALANCE is negative.



See also
More power with @functions
@functions A-Z