IF Function Examples

The =IF() function is a bit different from the other more traditional functions like =sum(), =avg() and =pmt(). These traditional functions compute a value. The =IF() function evaluates a logical expression and returns one of two values specified in the function.

Here are two examples,

ifex1.gif (2442 bytes)

In the example above the IF function in cell D3 prints "Average or above" or "below average" depending on the values in D1 and D2. If the expression D2>=D1 is true "Average or above" is printed, otherwise "below average" is printed. In the example above "Average or above" is printed because 93 is greater or equal to 89.

ifex2.gif (3361 bytes)

The example above is a bit more complicated and deals with percents. In the example above "Bear Market" is printed in cell D3 when the difference between D1 and D2 is greater than 20% of D1. If the difference between D1 and D2 is less than or equal to 20% of D1 "Not a Bear Market" is printed.