Click here for Introduction Click here for Table of Contents Click here for Examples and Special Topics
BarEnd.jpg (765 bytes)

  The IF Function

Another common spreadsheet task calculates a conditional decision. This is a fancy way of saying that if your calculations have one result, you want the worksheet to do one thing, but if they have a different result you want it to do something else.

A typical programming routine would translate this conditional decision as:

IF some condition is true

Then do something

otherwise, do something else.

If you have taken any programming courses, you have probably heard this referred to as an If…Then…Else routine.

You can build similar functions in Excel. The program's built-in IF function is designed for just this purpose.

The help file will tell you that the IF function has the following syntax:

IF(logical_test,value_if_true,value_if_false)

You may or may not find this description helpful. Let's try to decode it.

IF( ) This tells Excel what function to use.
logical_test This tells Excel what condition to test. It is normally a comparison between the contents of two worksheet cells. For example, you might compare whether the contents of one sell its larger than the contents of another cell (e.g., was this quarter's sales higher than last quarter's sales?).
value_if_true This tells Excel what formula to calculate if the comparison stated above turns out the way you expected (i.e., is "true"). If it is true, Excel uses this formula to calculate the contents of the cell holding the If function. As a (stupid) the example, if this quarter's sales prove higher than last quarters sales you can have the IF function make the cell say, "Very good".
value_if_false This tells Excel what formula to calculate if the comparison turns out other than you expected (i.e., is "not true", or "false"). In this case, Excel uses this formula to calculate the contents of the cell. If this quarter's sales were not higher than last quarter's sales, for example, the IF function could make the cell say, "You're fired".

Use the videos listed at the top of this page to become more familiar with this function.

Learn more

avi_icon.gif (229 bytes)

This video demonstrates a simple IF function (1.6 MB).

avi_icon.gif (229 bytes)

This video shows the results of a nested IF function (0.9 MB).

avi_icon.gif (229 bytes)

This video demonstrates building a nested IF function (2.5 MB).