How to Use the IF Function in MS Excel
The IF function in Microsoft Excel allows you to perform different calculations based on a true/false comparison. The IF function performs one calculation if the comparison is true, but performs an entirely different calculation if the comparison is false. The format of the IF function is "IF(logical_test,value_if_true,value_if_false)." You can also nest IF functions, such that you perform another IF comparison if the logical test is "true" or "false."
Instructions
-
-
1
Enter "=IF(logical_test," in the cell where you want the information displayed. The equal sign tells Excel to expect a function or calculation. The "logical_test" should be substituted with any comparison you want performed.
As an example, say you wanted to know how many hours of overtime you worked. The beginning of the function might read "=IF(A1<=40," which is read as "if the value in cell A1 is less than or equal to 40." If the cell A1 contained 39, the answer is true. If the cell A1 contained 60, the answer is false.
-
2
Add the "value_if_true" statement. In the example, the beginning of your IF function would now read "=IF(A1<=40,0," which tells the function to enter a zero if the value in A1 is less than or equal to 40 hours.
-
-
3
Add the "value_if_false" statement and end the function with an ending parenthesis. In the example, your complete function might be "=IF(A1<=40,0,A1-40)". The entire function is read, "If the value in A1 is less than or equal to 40, then enter zero. Otherwise, subtract 40 from the value in A1."
-
4
Enter another IF function in place of "value_if_true" or "value_if_false" if you need a more complex comparison. The format is exactly the same except you do not need another equal sign at the beginning.
As an example, say your boss only allows a maximum of 10 hours of overtime, which means your number of overtime hours can only be between zero and 10. Therefore, you can add another IF function in the "value_if_false" section. The complete function would be "=IF(A1<=40,0,IF(A1>50,10,A1-40))." Now the function reads, "If the value in A1 is less than or equal to 40, then enter zero. Otherwise, if the value in A1 is greater than 50, then enter 10. Otherwise, subtract 40 from the value in A1."
-
1