The IF function in Excel uses the syntax =IF(logical_test, value_if_true, value_if_false) to return different results based on a condition.
You can nest multiple IF formulas inside one another to evaluate several conditions and return tiered results.
Combining IF with AND or OR lets you test multiple criteria within a single logical test.
Common IF formula errors often stem from mismatched parentheses, missing arguments or incorrect data types.
The IF function in Excel is one of the most widely used logical functions in any spreadsheet. Many people search for the "IF/THEN formula," but in Excel the function is simply called IF. It lets you test a condition and return one value when the condition is true and a different value when it is false.
The basic syntax looks like this:
=IF(logical_test, value_if_true, [value_if_false])
Each argument plays a specific role:
logical_test: The condition you want to evaluate, such as A1>100 or B2="Yes."
value_if_true: The result the formula returns when the logical test is met. This can be a number, text string, cell reference or another formula.
value_if_false: The result the formula returns when the logical test is not met. This argument is optional, but leaving it out returns FALSE by default.
Argument | What It Does | Example Value |
|---|---|---|
logical_test | Evaluates a condition as TRUE or FALSE | D2>1000 |
value_if_true | Returns this result when the test is TRUE | 0.06 |
value_if_false | Returns this result when the test is FALSE | 0 |
This guide covers basic IF formulas, nested IFs for multiple conditions and combining IF with AND or OR. If you are brand new to the IF function, our introductory post covers the fundamentals of applying discounts to customer quotes based on a set of criteria being met. The examples below build on that foundation, but you can follow along even if you are starting here.
Before diving into more advanced scenarios, start with a straightforward example. Suppose you have a list of sales totals in column B and you want to flag every sale that meets or exceeds a $500 target.
=IF(B2>=500, "Met Target", "Below Target")
Here is how each part works:
Copy this formula down the column and Excel evaluates each row independently. You get an instant, at-a-glance view of which sales hit the mark and which fell short—and you can pair this with conditional formatting to add color-coded visual cues to your results. Once you are comfortable with this pattern, you are ready to layer in additional conditions using nested IF formulas.
As amazing as the IF formula is alone, it really comes into its own when used in groups. This section introduces you to nested IF functions. Nested IF formulas help you calculate more complex discounts, such as multiple rates for multiple tiers of purchasing.
Problem:
IF the number of units is over 1,000, check to see IF the number is over 5,000. If it is, give the customer a 6% discount. Otherwise, give the customer a 3% discount. If the number of units is not over 1,000, the customer receives no discount.
=IF(D2>1000, IF(D2>5000, 0.06, 0.03), 0)
Nested IF formulas work well for tiered logic, but sometimes you need to test several criteria at the same time. That is where the AND and OR functions come in. Wrapping them inside an IF formula lets you evaluate multiple conditions in a single logical test.
Using IF with AND
The AND function requires every condition to be true before the IF formula returns the "true" result. For example, suppose you want to offer a 10% discount only when a customer orders more than 1,000 units and holds a "Gold" membership level:
=IF(AND(B2>1000, C2="Gold"), 0.10, 0)
Using IF with OR
The OR function returns true when at least one condition is met. For instance, you might offer an 8% discount to any customer who either orders more than 5,000 units or has "VIP" status:
=IF(OR(B2>5000, C2="VIP"), 0.08, 0)
You can also combine AND and OR in the same formula for more complex scenarios. Just be sure to close every parenthesis, because mismatched parentheses are the most common source of errors in these formulas.
Even experienced Excel users run into issues with IF formulas. Here are the most frequent problems and how to resolve them:
The IF formula gives you a powerful tool for adding true/false logic to your data—from discount tiers to finance formulas—helping speed decision-making and save you time on otherwise repetitive tasks.
Once you are comfortable with IF, explore related functions that extend the same logic across larger data sets. IFS lets you evaluate multiple conditions without nesting. SUMIF and COUNTIF apply conditional logic to sums and counts. SUMIFS handles multiple criteria in a single formula. Each of these builds on the foundation you have practiced here and supports data-driven decision making across your organization.
Pryor Learning offers hands-on Excel training courses designed for every skill level, from spreadsheet basics to advanced formulas and data analysis. With a PryorPlus membership, you get unlimited access to live seminars, On-Demand courses and downloadable resources so you can keep sharpening your skills at your own pace.