IF Function - Excel


Overview


The IF function in Excel is a useful tool for making decisions in your spreadsheets. It helps you check if a certain condition is met, giving one result if it's TRUE and another if it's FALSE. You can easily use it to create more dynamic and responsive formulas in your Excel work. This function can also be nested into other functions or even within another IF function.

An example of the IF function in Excel

Example:

=IF(C2>10, "Greater than 10", "Less than 10")

Syntax:

=IF(logical_test, value_if_true, value_if_false)

logical_test: The condition or criteria that you want to evaluate.

value_if_true: The value that is returned if the logical_test is true.

value_if_false: The value that is returned if the logical_test is false.


TRUE Example


In this example, the IF function gives us the TRUE value result because C2 equals 12 and that number is greater than 10. In this function our TRUE value response was set as “Greater than 10” so that ended up being our output.

An example of the IF function in Excel where we get a TRUE result

FALSE Example


In this example, the IF function gives us the FALSE value result because C2 equals 5 and that number is less than 10. In this function our FALSE value response was set as “Less than 10” so that ended up being our output.

An example of the IF function in Excel where we get a FALSE result

Nested Example


In this example, I'll demonstrate how the IF function can be used within another IF function. The first IF function is checking to see whether C2 is greater than 10 and since C2 is 5, this is FALSE and it now goes to the IF function that is present in our FALSE value result. This next IF function is checking if D2 equals “Red” and since it does equal “Red” then the output is “Color is Red” which is our TRUE value result. If D2 would not have been “Red” then our output would’ve been “Color is not Red” which is our FALSE value result.

An example of the IF function in Excel where we nest it inside another IF function

Interactive GSheet