## How to use the IF function in Excel

The IF function is the most important Logical function in Excel

The IF function is used to test for a condition and return one value if the condition is TRUE

and another value if the condition is FALSE

To illustrate how the IF function works, let's look at an example

Here we have a table of data that consists of Item and Quantity columns

Let's use the IF function to return a value of "Reorder" if the quantity is less than 10

To get started, let's begin by entering the IF command

As you can see, the IF function takes 3 parameters, with the last parameter being optional

The first parameter is the condition or value to test

In our example, we want to test to see if the value in cell B2 is less than 10

so we will enter B2<10 as the condition to test for

The second parameter we will need to enter is the value to return if the condition is TRUE

In our example, we will enter the value "Reorder"

This means that if the value in cell B2 is less than 10, the IF function will return "Reorder"

The third parameter is optional

If provided, it contains the value that will be returned if the condition evaluates to FALSE

To highlight a common mistake, we will leave this parameter out in our example

Now that we have entered all of the IF function's parameters

let's complete the command to examine the result

You should see the value "Reorder" appear in cell D2

Since cell B2 contains the value of 7, which is less than 10, the if function will return "Reorder"

Now let's copy our formula into cells D3 to D5

Notice that in cells D3 and D4 the value FALSE appears

Since we didn't specify a third parameter in our formula, the IF function will return FALSE

when the condition evaluates to FALSE

Many make the mistake of assuming that by leaving out the third parameter

the IF function will return a blank result when the condition is FALSE

To avoid unexpected results, it is a good idea to always enter the third parameter

So let's rewrite our formula to return a blank value when the condition evaluates to FALSE

In cell E2, we will enter our IF command and again use B2<10 for the first parameter

and "Reorder" for the second parameter

This time, however, we will enter 2 quotation marks ("") as a third parameter

This represents a blank value or empty string

Now let's complete the command and copy our formula into cells E3 to E5

This time, we can see that instead of returning FALSE for rows 3 and 4

the if function has returned a blank cell

So when you write your IF function, remember to include both the value to return when the condition is TRUE

as well as the value to return when the condition is FALSE

This completes our example of how to use excel's IF function

if you would like to see more IF examples

or would like to download the sample data we used for this tutorial