- IF(Something is True, then do something, otherwise do something else)

So an IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.

If you want to skip ahead to working with multiple IF statements, see: Advanced IF functions – Working with nested formulas and avoiding pitfalls.

## Simple IF examples

- =IF(C2=”Yes”,1,2)

In the above example, cell D2 says: *IF(C2 = Yes, then return a 1, otherwise return a 2)*

- =IF(C2=1,”Yes”,”No”)

In this example, the formula in cell D2 says: *IF(C2 = 1, then return Yes, otherwise return No)*

As you see, the IF function can be used to evaluate both text and values. It can also be used to evaluate errors. You are not limited to only checking if one thing is equal to another and returning a single result, you can also use mathematical operators and perform additional calculations depending on your criteria. You can also nest multiple IF functions together in order to perform multiple comparisons.

**NOTE:** If you are going to use text in formulas, you need to wrap the text in quotes (e.g. “Text”). The only exception to that is using TRUE or FALSE, which Excel automatically understands.

## How to get started

The best way to start writing an IF statement is to think about what you are trying to accomplish. What comparison are you trying to make? Many times, writing an IF statement can be as simple as thinking through the logic in your head: “what should happen if this condition is met vs. what should happen if it’s not?” You will always want to make sure that your steps follow a logical progression, or else your formula won’t do what you think it should. This is especially important when you create complex (nested) IF statements.

## More IF examples

- =IF(C2>B2,”Over Budget”,”Within Budget”)

In the above example, the IF function in D2 is saying *IF(C2 Is Greater Than B2, then return “Over Budget”, otherwise return “Within Budget”)*

- =IF(C2>B2,C2-B2,0)

In the above illustration, instead of returning a text result, we are going to return a mathematical calculation. So the formula in E2 is saying *IF(Actual is Greater than Budgeted, then Subtract the Budgeted amount from the Actual amount, otherwise return nothing).*

- =IF(E7=”Yes”,F5*0.0825,0)

In this example, the formula in F7 is saying *IF(E7 = “Yes”, then calculate the Total Amount in F5 * 8.25%, otherwise no Sales Tax is due so return 0)*

**Best Practices – Constants**In the last example, you see both “Yes”, and the Sales Tax Rate (0.0825) entered directly into the formula. It is generally not a good practice to put literal constants (values that may need to change from time to time) directly into formulas, because they can be hard to find and change in the future. It’s much better to put constants into their own cells, where they are out in the open and easily found and changed. In this case, it’s OK, because there’s only one IF function and the Sales Tax Rate will rarely change. Even if it does, it will be easy to change it in the formula.