The IF function is the most popular type of function. The IF function evaluates a condition and if that condition is true, it will return a certain value, and if it is false, it will return a different value. This is the most common type of decision-making function that is used in any programming language and also is probably one of the most common functions used in Microsoft Office Excel worksheets.
The syntax for writing an IF function in Microsoft Excel is:
=IF(logical_test, value_if_true, value_if_false)
The "logical_test" is any value or expression that can be either true or false. This is a condition that gets evaluated for the IF function. For example 20=30 is a valid expression. It would be an expression that is false. Another example of what the "logical_test" expression can be is 5=5, and this one is true.
The second parameter called "value_if_true", is the value that gets returned from this IF function if the "logical_test" is true. For example if the "logical_test" was 5=5, then this if function would return "value_if_true" and if the "logical_test" was 20=30, then this IF function would NOT return "value_if_true".
The third parameter called "value_if_false" is optional. This is what gets returned if the "logical_test" is false. From the above example, when the "logical_test" was 20=30, this "value_if_false" gets returned from the IF function.
As can be seen, first a logical test is performed and if the value is true, the second value is returned, and if it is false, the third value is returned in this IF function syntax.
Here it is an example of an IF function:
=IF(3 < 50, 1, 0)
This if function will return the number 1 if the condition is true and it will return 0 if the condition is false. If you placed this if function into a cell in an Excel worksheet you should get the number 1 because the statement 3 < 50 is true.
It is possible to nest IF functions within an IF function. In the above example instead of returning one we could have another IF statement that gets executed instead of one being displayed, same thing with the zero. That way we can have nested if statements as parameters and that will enhance our logic that we want to use for the IF functions and gives us more options to customize the results.
This Microsoft Excel IF function basically is a fork in the road. When the condition is true we are going to take one path, and if it is false we are going to take a different path.
Published by Kantus
I love writing short stories and humor articles, but tend to stick with topics that are discoverable by search engines and capable of spreading virally. View profile
- Introduction to Microsoft Excel
- Preparing a Chart using Microsoft Excel
- How to Protect Cells in Microsoft Excel
- Step-by-Step Microsoft Excel Tutorial for Beginners
- Using Advanced Functions in Excel



