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

# Conditional functions

## if

Returns one of two values based on a condition.

```text theme={null}
if(condition, value_when_true, value_when_false)
```

Example:

```text theme={null}
if(Revenue > 0, `Gross Profit` / Revenue, 0)
```

The three arguments are:

1. A condition
2. The result when the condition is true
3. The result when the condition is false

The two result expressions should represent compatible types.

You can nest `if` calls:

```text theme={null}
if(Revenue > 100, "high", if(Revenue > 50, "medium", "low"))
```

For several categories or exceptions, a dimension-based formula may be easier to maintain than a deeply nested expression.
