IF Function

The IF function tests a condition and returns one value if it's true and another if it's false - the foundation of conditional logic in Excel.

Syntax

=IF(logical_test, value_if_true, value_if_false)

Example

=IF(B2>=50, "Pass", "Fail")
' Returns "Pass" if the score in B2 is 50 or more, otherwise "Fail"

Nested IF Statements

Multiple IF functions can be nested to handle more than two outcomes.

=IF(B2>=90, "A", IF(B2>=75, "B", IF(B2>=50, "C", "D")))

Combining IF with Logical Functions

AND and OR let a single IF statement check multiple conditions at once.

=IF(AND(B2>=50, C2="Present"), "Eligible", "Not Eligible")
For more than three or four outcomes, IFS is usually cleaner and easier to read than deeply nested IF statements.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course