IF formula and example in Excel and Google Sheets

Formula, examples and how to use it

=IF(logical_expression, value_if_true, value_if_false)

One of the most popular functions used in Excel and Google Sheets, and returns one value if a logical expression is 'TRUE' and another if it is 'FALSE'.

IF formula and example in Excel and Google Sheets

IF function in Excel and Google Sheets

Example:

If a student has a score greater than 59 then "Pass" else "Fail"

=IF(A2>59,"Pass","Fail")

If an item price is less than or equal to 1000 then “Within Budget" else "Over Budget"

=IF(A2<=1000,"Within Budget", "Over Budget")

IF can be also used with AND and OR functions. AND function returns a value if two conditions are meet and OR function returns a value if one of two conditions are met.

AND Function

If an item price is between 200 and 1000 then "Buy" else "Review" before making a decision and the formula will look like this.

=IF(AND(A2<=1000,A2>=200),"Buy","Review")

OR Function

If an item colour is Red, Blue or White then "Popular Colours", else "Other Colours". The formula will look like this.

=IF(OR(A2="Red",A2="Blue",A2="White"),"Popular Colours","Other Colours")

Check below live Google Sheets for Calculating Student Grades, How to use AND & OR function with IF function and Logical operators

Excel and Google Logical Operators
Excel and Google Logical Operators

LIVE IF FUNCTION AND EXAMPLE

IF FUNCTION AND EXAMPLE