Excel IF Function


What does it do?

The Excel IF function allows you to perform a logical test, if the result is true, it will return one result, opposingly, it will return another if it is found to be false.  The logical test uses the logical expressions, GREATER THAN, LESS THAN, NOT EQUAL TO, EQUAL TO, GREATER THAN or EQUAL TO, LESS THAN or EQUAL TO and EQUAL TO.  Expressions use the logical operators <, >, <>, = for numerical and text criterion.  You can set all manner of returns into the TRUE or FALSE results, this can range from text, number and additional formulations.


Syntax Explained

Excel IF function in the formula bar showing syntax.

Logical _test: This is where the condition is tested to determine a TRUE or FALSE result.

Value_if_true: This is the value to return if the logical test if found to be TRUE.

Value_if_false: This is the value to return if the logical test if found to be FALSE.


Examples

1. IF to demonstrate the pure basics.

Example of an Excel IF function to return one text string if the cell is equal to number, if not, return another text string.
Example of an IF function to return one text string if the cell is greater than or equal to number, if not, return another text string.

Let’s begin with a basic version by testing each value in the Number column and when the number 2 is found it should show a TRUE result, if not found, it should show a FALSE result.  In the example above you can see the TRUE result on row 5.

2. IF cell is GREATER THAN or EQUAL TO then output a TEXT result.

Example of an Excel IF function to return one text string if the cell is greater than or equal to number, if not, return another text string.

We can determine if a result passed or didn’t by using the >= logical operator. The return can be set to show a TRUE result of “Pass” when the value in the Result column is GREATER THAN or EQUAL to 60.  In our example above there is only one fail on Row 5.

3. IF cell IS EQUAL TO a TEXT STRING then do a CALCULATION.

Example of an Excel IF function performing one calculation if the cell is equal to text string, if not, do a different calculation.

Using the same example above slightly expanded, I’ve set each row a SCORE TO DATE value in column B.  The pass / fail result is now in column E and uses the same IF statement as above in point 2.  The IF statement in column G now does a logical test on column E and adds 10 on for a PASS and no addition for a FAIL to give the Final Score shown in column H

Pro Tip

There is a whole world full of uses for the IF function which is not for this short introduction.  In time, I will be adding more to this article by way of related links below.  For now, this should whet your appetite!