Symon He
Person sitting in front of laptop typing

Excel is often used as a simple spreadsheet application to keep track of facts and figures, add numbers together, or do other straightforward arithmetic functions. But Excel has grown from its simple spreadsheet days to a complex program that allows you to embed programming in the spreadsheet itself. The programming functions in Excel can make it a lot easier to analyze the data within the spreadsheet or create generic calculations that handle differing inputs.

The IF function in Excel is a good example of a simple function that can make your life easier and help you perform more advanced calculations and conditional formatting.

I wrote this tutorial with the beginner in mind, but to understand and follow the tutorial, you need to know how to add data to cells and perform basic functions with Excel spreadsheets. 

Microsoft Excel for Complete Beginners w/ Case Studies

Last Updated July 2023

  • 200 lectures
  • All Levels
4.3 (617)

Master or review Excel with 10 real world case studies. Packed with supplemental material for analysts. | By Symon He, Travis Chow

Explore Course

Understanding the IF function

The syntax of the IF statement in Excel is as follows:

IF(condition, [value_if_true], [value_if_false] )

The condition must be a value or a logical function that evaluates to either TRUE or FALSE.  Reading it as an IF-THEN statement can help you understand how to use this function. If the condition is true, then the value in the second parameter will appear in the cell. If it does not meet the condition, the third parameter you used in the function will be displayed.

A common conditional used in IF statements are expressions to check the relationship between two values in your spreadsheet. For example, A1 > B1 is a logical expression that checks if the value in cell A1 is greater than the value in cell B1. If the values were 6 and 3, then 6 > 3 would evaluate to TRUE.

You can use any of these comparison operators in the condition statement:

Let’s look at a simple example.

IF( x > 3, x * 3, x / 3 )

Here we can read this statement as:

If x is greater than 3 is TRUE, then return the value x times 3, else if x greater than 3 is FALSE, then return the value x divided by 3.

So, what the value x is 6, what is the result?

IF( 6 > 3, 6 * 3, 6 / 3 ) = 6 * 3 = 18

Here, since x is greater than 3, the condition evaluates to TRUE, and the IF formula returns the value_if_true, which in this case is x * 3 or 6 * 3 = 18.

Now, if x is 1, what is the result?

IF( 1 > 3, 1 * 3, 1 / 3 ) = 1 / 3 = 0.333333333

Here, since x is not greater than 3, the condition evaluates to FALSE, and the IF formula returns the value_if_false, which in this case is x / 3 or 1 / 3 = 0.333333333.

In the simple examples above, we used the IF function to return a calculated numeric value. However, you can use the IF function for so much more.

Three examples of using the IF function

Segmenting datasets using the IF function

A simple and frequent use case for the IF function is to identify subsets of a given dataset that meet criteria and label that data.

For example, if we have a list of student scores on a pass or fail exam where scores < 70 is a FAIL and scores >= 70 is a PASS, we can use an IF function like this:

IF( SCORE < 70, "FAIL", "PASS")

Notice, the value_if_true and value_if_false are in quotations. If we want the results to be text, then we must enclose the values in quotation marks. Using that formula above in a spreadsheet, we can let Excel label all the grades in a spreadsheet as PASS or FAIL instead of figuring it out from the scores ourselves.

Nesting IF functions for categorizing data

This example is similar to our last example, but while our last example had two labels, this one will have more. Let’s say you want to categorize the stores of a multi-unit restaurant chain based on their sales growth, where:

If we had data that looked like this, what would the formula in the Category column look like?

Store 1-5%
Store 24%
Store 36%

Well, we could do something like this.


Notice the nested IF function inside the first IF function. The second IF function is the value_if_false for the first IF function.

When we’re doing simple data categorization with a small number of categories, using nested IF functions is an easy solution. The number of IF functions you need will be n – 1, where n is the number of labels you are using.

Using other functions in the condition

We’ve used the IF function inside of another IF function. You can also use other functions inside the IF function. Here are some useful examples.

What do you think this does?

IF(ISBLANK(A1), 0, A1)

In Excel, there is a class of IS functions that allow you to check various attributes of a cell. ISBLANK above is checking whether the cell, A1, is blank. If A1 is blank, then the expression evaluates to true. Other popular IS functions include ISNUMBER, ISERROR, and ISTEXT. Using these functions with the IF function can help you check the attributes of a cell efficiently.

What do you think these do?

IF(AND(A1 >= 9, A1 <= 12), "HS Student", " ")
IF(OR(A1 = "Toyota", A1 = "Honda", A1 = "Mitsubishi", "Japanese Car", " ")

In Excel, there are also logical operator formulas we can use with the IF function to allow us to check multiple conditions simultaneously. 

The AND function used in the first example requires that all of the conditions inside the AND function be true for the entire expression to evaluate to true. Here, A1 must be between 9 and 12, inclusive, which in this case represents the student’s grade level.

The OR function in the second example requires only one of the conditions inside it to be true for the entire expression to evaluate to true. Here, we are labeling car manufacturers who are from Japan.

What else can you use IF functions for?

The examples above are only some of the things you can use the IF function for. In combination with other functions and techniques, you can use the IF function to help answer questions based on your data set. Some examples are:

As you become more familiar with Excel and the IF function, you’ll discover new uses specific to your domain and needs.

Page Last Updated: September 2021

Top courses in Microsoft Excel

Microsoft Excel - Data Analytics Power Query and PivotTables
Kyle Pew, Office Newb
4.8 (1,582)
Microsoft Excel: Data Visualization with 20+ Excel Charts
Maven Analytics, Chris Dutton
4.6 (49,160)
Microsoft Excel - Excel from Beginner to Advanced
Kyle Pew, Office Newb
4.6 (445,737)
Microsoft Excel: Data Analysis with Excel Pivot Tables
Maven Analytics, Chris Dutton
4.7 (64,177)
Data Analysis Essentials Using Excel
Symon He, Travis Chow
4.6 (12,974)
Microsoft Excel - Excel from Beginner to Advanced 2024
Warrick Klimaytys
4.6 (13,686)
Microsoft Excel Pro Tips: MS Excel from Beginner to Advanced
Maven Analytics, Chris Dutton
4.6 (5,718)

More Microsoft Excel Courses

Microsoft Excel students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo