# IF FUNCTION

**IF FUNCTION/SYNTAX**

**This tutorial explains how to use IF function in excel with syntax and examples.**

**What is IF function ?**

### In Microsoft Excel IF function returns one value if the condition is TRUE, or another value if the condition is FALSE.

### The IF function is a built-in function in Excel that is categorized as a *Logical Function*. It can be used as a worksheet function in Excel. As a worksheet function, the IF function can be entered as part of a formula in a cell of a worksheet. A simple example and syntax is here.

**Syntax**

### The syntax of IF function

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

### Example 1

### Based on the Excel spreadsheet above, the following IF examples would return:

### =IF(A1>5, “Greater”, “Smaller”)

*Result:* “Greater”

## Example 2 :

### What Does It Do?

This function tests a condition.

If the condition is met it is considered to be TRUE.

If the condition is not met it is considered as FALSE.

Depending upon the result, one of two actions will be carried out.

### Syntax

=IF(Condition,ActionIfTrue,ActionIfFalse)

The Condition is usually a test of two cells, such as A1=A2.

The ActionIfTrue and ActionIfFalse can be numbers, text or calculations.

### Formatting

No special formatting is required.

### Example 1

The following table shows the Sales figures and Targets for sales reps.

Each has their own target which they must reach.

The =IF() function is used to compare the Sales with the Target.

If the Sales are greater than or equal to the Target the result of Achieved is shown.

If the Sales do not reach the target the result of Not Achieved is shown.

Note that the text used in the =IF() function needs to be placed in double quotes “Achieved”.

### =IF(C31>=D31,”Achieved”,”Not Achieved”)

=IF(C32>=D32,”Achieved”,”Not Achieved”)

=IF(C33>=D33,”Achieved”,”Not Achieved”)