The IF Function
Make your spreadsheet respond differently depending on a condition.
Compatibility: All Excel versions
What You'll Learn
- The three parts of an IF statement
- How comparison operators work
- Why text results need quotation marks and numbers don't
The IF function checks whether something is true or false, and returns a different result for each case:
=IF(A1>=60,"Pass","Fail")
Read this as: "If the value in A1 is 60 or greater, show Pass. Otherwise, show Fail." IF always takes three parts, separated by commas: the condition to check, what to show if it's true, and what to show if it's false.
Comparison Operators
IF conditions are built using comparison operators: = (equal to), <> (not equal to), >, <, >=, <=.
Text Results Need Quotation Marks
Notice "Pass" and "Fail" are wrapped in quotation marks — any text result in a formula needs quotes around it. Numbers don't: =IF(A1>=60,1,0) is also valid, with no quotes needed.
Common Mistakes
- Forgetting the quotation marks around a text result
- Mixing up > (greater than) and >= (greater than or equal to) at a boundary value
Practice Exercise
Build a column of 10 test scores. Next to each, use IF to show "Pass" for 60 or above and "Fail" for anything below.
Key Takeaways
- IF needs a condition, a true result, and a false result, in that order
- Text results need quotes; numbers don't
- Comparison operators: = <> > < >= <=