How to use IF function in Excel?

The IF function in Excel is used to make logical comparisons between a value and what you expect. The basic syntax of the IF function is:

=IF(logical_test, value_if_true, value_if_false)

Here’s how each part works:

  • logical_test: This is the condition you want to test. It can be any expression that returns TRUE or FALSE. For example, `A1 > 10`.
  • value_if_true: This is the value that will be returned if the `logical_test` evaluates to TRUE. This can be a number, text, formula, or cell reference.
  • value_if_false: This is the value that will be returned if the `logical_test` evaluates to FALSE. Like `value_if_true`, this can be a number, text, formula, or cell reference.

Example

Suppose you have a list of scores in Column A and you want to mark each score as “Pass” if it is 60 or higher, and “Fail” if it is lower than 60.

You would enter the following formula in cell B1, assuming the score is in A1:

=IF(A1 >= 60, "Pass", "Fail")

Nested IF Statements

You can also nest multiple IF functions within each other to test multiple conditions. For example, if you want to assign grades based on different score ranges, you could use:

=IF(A1 >= 90, "A", IF(A1 >= 80, "B", IF(A1 >= 70, "C", IF(A1 >= 60, "D", "F"))))

This formula checks:

  • If the score is 90 or more, it returns “A”.
  • If not, it checks if the score is 80 or more, then returns “B”, and so on.

Tips

  • Ensure to use the correct operators for your logical tests, such as `>`, `<`, `>=`, `<=`, `=`, or `<>`.
  • Be mindful of the order of your conditions in nested IF statements, as they are evaluated sequentially.
  • Remember that nesting too many IF functions can make your formula complex and hard to read, so consider using other functions like SWITCH or IFS for more complex scenarios (available in Excel 2016 and later).

By using the IF function effectively, you can automate decision-making processes and increase the functionality of your spreadsheets.

Unlock Your Potential

Excel

Basic - Advanced

Access

Access Basic - Advanced

Power BI

Power BI Basic - Advanced

Help us grow the project