---
title: IF
url: https://www.tines.com/docs/formulas/functions/if/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/docs/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# IF

*[View on tines.com](https://www.tines.com/docs/formulas/functions/if/)*

If `condition` is `TRUE` returns second argument, if `FALSE` returns `null` or the third argument.

**Categories:** Logic

## Syntax

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

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "value": 5
  }
}
```

Formula:

```
IF(my_action.value>5, "true")
```

Output:

```json
null
```

### Example 2

Input:

```json
{
  "my_action": {
    "value": 5
  }
}
```

Formula:

```
IF(my_action.value>5, "true", "false")
```

Output:

```json
false
```

### Example 3

Input:

```json
{
  "my_action": {
    "value": 5
  }
}
```

Formula:

```
IF(my_action.value>1, "true", "false")
```

Output:

```json
true
```

### Example 4

Input:

```json
{
  "my_action": {
    "value1": 5,
    "value2": 50
  }
}
```

Formula:

```
IF(AND(my_action.value1<my_action.value2, my_action.value<100), my_action.value1, "Value is not within the range")
```

Output:

```json
5
```

### Example 5

Input:

```json
{
  "my_action": {
    "value1": 500,
    "value2": 50
  }
}
```

Formula:

```
IF(AND(my_action.value1<my_action.value2, my_action.value<100), my_action.value1, "Value is not within the range")
```

Output:

```json
"Value is not within the range"
```

## Sample actions

```json
{
  "standardLibVersion": "13",
  "actionRuntimeVersion": "1",
  "agents": [
    {
      "disabled": false,
      "name": "IF",
      "description": null,
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "if": "=IF(my_action.num = 3, my_action.fruit, my_action.veg)",
          "less": "=IF(my_action.num < 3, my_action.fruit)",
          "greater": "=IF(my_action.num > 3, my_action.fruit)",
          "and": "=IF(AND(my_action.num > 1, my_action.num <5 ), my_action.fruit)",
          "or": "=IF(OR(my_action.num = 2, my_action.num =3 ), my_action.fruit)"
        }
      },
      "position": {
        "x": -420,
        "y": -5805
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "num": 2,
          "fruit": "apple",
          "veg": "carrot"
        }
      },
      "position": {
        "x": -420,
        "y": -5895
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 0
    }
  ],
  "diagramNotes": []
}
```
