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

# Ifelse

# \$ifelse

The `$ifelse` operator evaluates a condition and returns one of two values based on the result.

## Input

* An array containing exactly three values: the condition to evaluate, the value to return if true, and the value to return if false

## Output

* The second value if the condition is truthy, the third value otherwise

## Examples

### Basic Conditional

```json theme={null}
{
  "$ifelse": [
    {
      "$gt": [
        {
          "$input": "score"
        },
        90
      ]
    },
    "A",
    "B"
  ]
}
```

Result: `"A"` if score is greater than 90, otherwise `"B"`

### Conditional with Field Access

```json theme={null}
{
  "$ifelse": [
    {
      "$eq": [
        {
          "$input": "status"
        },
        "active"
      ]
    },
    {
      "$input": "active_date"
    },
    {
      "$input": "inactive_date"
    }
  ]
}
```

Result: The active\_date field if status is "active", otherwise the inactive\_date field
