> ## 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.

# Let

# \$let

The `$let` operator declares a variable in the current scope.

## Input

* An array containing exactly two values: the variable name (string) and the value to assign to the variable

## Output

* The assigned value

## Examples

### Basic Variable Assignment

```json theme={null}
{
  "$let": [
    "x",
    42
  ]
}
```

Result: `42`

### Assign Field Value to Variable

```json theme={null}
{
  "$let": [
    "user_name",
    {
      "$input": "name"
    }
  ]
}
```

Result: The value of the name field, which is also stored in the user\_name variable

### Use in a Block

```json theme={null}
{
  "$block": [
    {
      "$let": [
        "total",
        {
          "$add": [
            {
              "$input": "price"
            },
            {
              "$multiply": [
                {
                  "$input": "price"
                },
                0.1
              ]
            }
          ]
        }
      ]
    },
    {
      "$var": ["total"]
    }
  ]
}
```

Result: The calculated total value including tax
