The IF function is one of the most widely used logical functions in Excel. It evaluates a condition you specify and returns one value when the condition is true and a different value when it is false. Although many people search for "if then Excel," the function in Excel is simply called IF. The IF/THEN logic is built into the formula's structure.
The generic syntax for an IF formula in Excel looks like this:
=IF(logical_test, value_if_true, value_if_false)
Here is what each argument means:
| Argument | What It Does |
|---|---|
| logical_test | The condition you want to evaluate (e.g., A1>100) |
| value_if_true | The result returned when the condition is met |
| value_if_false | The result returned when the condition is not met |
The IF function works in all modern versions of Excel as well as Google Sheets, so the skills you learn here apply across platforms.
Sometimes you need your spreadsheet data to tell you more about itself. The versatile IF function is how you can turn raw numbers into useful information.
For example: Your wholesale company charges different rates depending on the size of bulk orders – customers who order more receive volume discounts. You want a way to quickly calculate the volume discount on a batch of orders so your sales team can deliver the correct quotes to their customers. In a nutshell, you need to calculate your cost and volume numbers into a price for your customers based on an additional bit of logic. This kind of pricing scenario often pairs well with Excel finance formulas for more advanced financial modeling.
Here is how your data might look in a simple spreadsheet:
The sections below walk through how to build this formula step by step.
To set up an IF function, try thinking about your problem in natural language:
Problem: IF(the number of units is over 1000, the customer receives a volume discount of 3%, otherwise the customer receives no discount).
Now, just fill in the cells and values for the statement:
=IF(D2>1000, 0.03,0)
If you are still confused about how to use an IF function, Excel offers some help:
1) Click the Formulas tab, then click Insert Function
2) Select IF from the Insert Function dialog box; click OK.
3) Fill in the function arguments in the next dialog box. The dialog box includes prompts to help you setup your IF function. Click OK. Excel will populate the cell with the function in the correct format.
Once you are comfortable with the basic IF function, you can build more complex formulas using nested IFs. For example, nested IF functions can help you calculate tiered discounts with multiple rates for different purchasing levels.
IF(the number of units is over 1000, check to see IF(the number is over 5000, give the customer a 6% discount, otherwise give the customer a 3% discount), if the number of units is not over 1000 the customer receives no discount).
=IF(D2>1000, IF(D2>5000, 0.06, 0.03), 0)
Even experienced Excel users run into errors when writing IF formulas. Here are the most common problems and how to resolve them:
As your spreadsheet logic grows more complex, several functions can simplify your formulas and make them easier to maintain:
Choosing the right function for the job keeps your formulas readable and reduces the chance of errors as your workbooks grow.
The IF function gives you a powerful tool for adding true/false logic to your data that will help speed decision-making (such as discounts!) and save you time on repetitive tasks.
Mastering IF/THEN logic in Excel opens the door to more advanced skills like dynamic reporting, conditional formatting and automated data validation. If you want to go deeper and build real confidence with formulas, check out Pryor Learning's Excel training courses for hands-on instruction you can apply right away.