> ## Documentation Index
> Fetch the complete documentation index at: https://guide.recital.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Formula transformation

# Formula Transformations

Formulas let you combine multiple operations into a single transformation. Instead of creating separate steps for each calculation, write one formula that does it all.

## Syntax

```
FUNCTION(argument1, argument2, ...)
```

* **Column names** — Use the column name directly: `Amount`, `Fee`, `Rate`
* **Column names with spaces or special characters** — Wrap in brackets: `{Settled Amount}` or `[Settled Amount]`
* **Numbers** — Use directly: `100`, `2.5`, `0`
* **Text** — Wrap in double quotes: `"-"`, `"USD"`
* **Nesting** — Any argument can be another formula: `ROUND(SUM(Amount, Fee), 2)`

## Available Functions

### Math

| Function   | Description                                       | Example                     |
| ---------- | ------------------------------------------------- | --------------------------- |
| `SUM`      | Add values together                               | `SUM(Amount, Fee)`          |
| `SUBTRACT` | Subtract values                                   | `SUBTRACT(Amount, Fee)`     |
| `MULTIPLY` | Multiply values                                   | `MULTIPLY(Amount, Rate)`    |
| `DIVIDE`   | Divide (safe — returns empty if dividing by zero) | `DIVIDE(Amount, 100)`       |
| `AVERAGE`  | Average of values                                 | `AVERAGE(Amount, Fee, Tax)` |
| `ABS`      | Absolute value                                    | `ABS(Amount)`               |
| `ROUND`    | Round to N decimal places                         | `ROUND(Amount, 2)`          |

### Text

| Function | Description                    | Example                            |
| -------- | ------------------------------ | ---------------------------------- |
| `LEFT`   | First N characters             | `LEFT(Reference, 3)`               |
| `RIGHT`  | Last N characters              | `RIGHT(Reference, 4)`              |
| `TRIM`   | Remove leading/trailing spaces | `TRIM(Name)`                       |
| `UPPER`  | Convert to uppercase           | `UPPER(Currency)`                  |
| `LOWER`  | Convert to lowercase           | `LOWER(Status)`                    |
| `CONCAT` | Join values together           | `CONCAT(FirstName, " ", LastName)` |

### Logic

| Function | Description                            | Example                     |
| -------- | -------------------------------------- | --------------------------- |
| `IF`     | Conditional: IF(condition, then, else) | `IF(Amount > 0, Amount, 0)` |

**IF conditions:** `>`, `<`, `>=`, `<=`, `=`, `!=`

### Arithmetic Operators

You can also use standard arithmetic directly:

```
Amount + Fee
(Amount - Fee) * Rate
Amount / 100
```

Division by zero is handled safely (returns empty).

## Examples

### Calculate a percentage

```
ROUND(MULTIPLY(DIVIDE({Difference (fee dr)}, Amount), 100), 2)
```

### Sum two columns and round

```
ROUND(SUM(Amount, Fee), 2)
```

### Build a composite key

```
CONCAT(LEFT(Reference, 3), "-", UPPER(Currency))
```

### Conditional value

```
IF(Amount > 1000, "high", "low")
```

### Net amount after fee and tax

```
SUBTRACT(Amount, SUM(Fee, Tax))
```

### Percentage with 4 decimal places

```
ROUND(DIVIDE(Fee, Amount), 4)
```

## Column Name Rules

| Column Name           | How to Reference                                   |
| --------------------- | -------------------------------------------------- |
| `Amount`              | `Amount`                                           |
| `Settled Amount`      | `{Settled Amount}` or `[Settled Amount]`           |
| `Difference (fee dr)` | `{Difference (fee dr)}` or `[Difference (fee dr)]` |

> If the column name contains spaces, parentheses, or special characters, wrap it in `{ }` or `[ ]`.

## Limits

* Maximum formula length: 1,000 characters
* Maximum nesting depth: 10 levels
* Maximum function calls per formula: 20
