---
title: IF
description: Learn how to use the IF function for conditional logic in calculated columns. Evaluate conditions, return values based on logic.
---
import { Steps } from '@astrojs/starlight/components';

# IF

The IF function is used to perform conditional logic. It evaluates a condition and returns one value if the condition is true and another value if the condition is false.

## Applicable to

Calculated Columns

## Return Value

* If the condition is true, the function returns the specific value.
* If the condition is false, the function returns the specific value.

## Remark

* The condition must be a logical expression that evaluates to either true or false.
* Nested IF functions can be used to create more complex conditional logic.
* It is important to ensure that the expressions provided are valid and do not produce errors, as this could cause the IF function to fail.

## Syntax

```
IF(<expression>,condition,condition)
```

## IF in Calculated Columns



| Parameter | Description |
|---|---|
| Expression | A placeholder in a function that is replaced with the column names. |
| Condition | The condition to evaluate against the expression. |

Steps to use IF in Calculated Columns

<Steps>
1. Write the IF function. For instance ```IF(<expression>,condition,condition)```
2. Replace `<expression>` with `VALUE([Column Name]),` replace `condition` with the actual case that you want to evaluate against expression what you expect to return when the condition turns true.Replace the **Column Name** with the actual name of your column required.
3. To learn how to add calculated columns in Infoveave, visit the section [Calculated Columns](/studio-v8/datasources/calculated-columns-datasource/).
</Steps>

**Example**

**Objective** Consider you want to create a sales bucket to categorize the unit price on the below table.

| Date       | Region | State or Province | Sales      |
|------------|--------|--------------------|-------------|
| 01-07-2024 | West   | Washington         | 94.56       |
| 02-07-2024 | West   | California        | 4390.3665   |
| 03-07-2024 | East   | New Jersey         | 53.8096     |
| 04-07-2024 | Central| Minnesota          | 803.4705    |


You can use the IF function like

```
IF(VALUE([Sales])>1000, "Profit", IF(VALUE([Sales])<999 AND VALUE([Sales])>200, "Average", "Loss"))
```

The new calculated column "Sales Bucket" will return

| Date       | Region | State or Province | Sales      | Sales Bucket |
|------------|--------|--------------------|-------------|---------------|
| 01-07-2024 | West   | Washington         | 94.56       | Loss          |
| 02-07-2024 | West   | California        | 4390.3665   | Profit        |
| 03-07-2024 | East   | New Jersey         | 53.8096     | Loss          |
| 04-07-2024 | Central| Minnesota          | 803.4705    | Average       |

