  Search

# How to Use the If Function in Excel

The If function in Excel lets you unroll formulas or perform a specific calculation only when a value condition is met. It makes the spreadsheet much more flexible in processing your data. In this article we will see how to use the if formula of Excel in a practical way. You regularly use the software Excel ? If so, you must have already seen or heard of the If function, one of those that makes the spreadsheet really powerful. It allows a logical comparison to be made between a value and the condition desired by the user. If this is respected, the instruction is executed. Otherwise, the formula executes an alternate statement.

## Excel: What are the use cases of the If function?

Concretely, here is how the structure of an If formula looks in Excel: If(logical_test;[value_if_true];[value_if_false]). You are told what each element of the formula corresponds to.

• logic_test represents the condition to be tested.
• [Value_if_true] : the value to return or an instruction to execute.
• [Value_if_false] corresponds to the value to return if the initial condition is not met.

### Concrete example of using the If formula

Let's take the basic example of a stock card in Excel. We want to check if a product is sold out. For this, we will display the word Exhausted when the stock value is 0. This is the main condition. When it is not respected, we will instead display the character string In stock.

Here is the formula to use with the function. Look at the screenshot below to find yourself in the cells: =SI(B2=0;”Sold out”;”In stock”). We start of course with the sign = before the beginning of the formula. You can also use other logical comparators in the condition of the Excel formula. Apart from the sign of equality, it is possible to condition the operator of superiority or inferiority. For example, in the tracking sheet, you can anticipate any stock shortage by defining a critical threshold.

Thus, when a quantity is less than a number (ex: 10), we display Critical stock in the corresponding column C. The formula would then be = YES (B2 = <10; "Critical Stock"; "In Stock").

This is how the If function works in Excel in a practical way. Note that in the case of our example, it is also possible to use conditional formatting to color a cell red when the stock quality is exhausted or has reached a critical level.

You can check out our article on using conditional formatting in Excel. As the name suggests, this involves applying specific formatting to a cell when the value in it meets a condition.