Excel IF Function: Conditions and Examples
By Szabó Gergő · Updated
The IF function tests a condition and returns one value when it is true and another when it is false. It is the foundation for conditional spreadsheet logic.
Syntax and arguments
=IF(logical_test, value_if_true, value_if_false)- logical_test
- A comparison that evaluates to TRUE or FALSE.
- value_if_true
- The value or calculation returned when the test passes.
- value_if_false
- The value or calculation returned when the test fails.
IF examples
Actual sales are in B2 and the target is 1000.
=IF(B2>=1000,"Met","Not met")Text results need quotation marks; the comparison includes exactly 1000.
Quantity is in B2 and unit price is in C2.
=IF(B2="","",B2*C2)The formula shows a blank until a quantity is entered, otherwise it calculates the line total.
A score is in B2 and attendance percentage is in C2.
=IF(AND(B2>=70,C2>=80%),"Pass","Review")AND requires both the score and attendance conditions to be true.
Common mistakes
Text is not quoted
Wrap literal text in double quotes, such as "Pass". Cell references and numbers stay unquoted.
Percent threshold uses 80 instead of 80%
Use 80% or 0.8 when the cell stores a real percentage.
Too many nested IF functions
Consider IFS, XLOOKUP, or a small mapping table when logic has many tiers.
IF FAQ
How do I test whether a cell is blank?
Use a comparison such as A2="" for cells that are empty or return an empty string.
Can IF perform a calculation?
Yes. Either result can be a formula expression, for example IF(B2>0,B2*C2,0).
How do I combine IF with AND or OR?
Place AND or OR inside logical_test. AND requires every condition; OR requires at least one.