# CLAMP

The CLAMP function restricts values within a specified range, ensuring that all samples are no less than a minimum value and no greater than a maximum value.

## Syntax

`CLAMP(field, min, max)`

### Parameters

#### field

Numeric expression. If the value is `null`, the function returns `null`.

#### min

The minimum value to clamp data into.

#### max

The maximum value to clamp data into.

## Examples

Clamps the `network.cost` field to a dynamic range, where the minimum is determined by the maximum of 5 and `network.bytes_in`, and the maximum is `network.bytes_in` divided by 100, then keeps only the clamped cost and timestamp.

```esql
TS k8s
| EVAL full_clamped_cost = clamp(network.cost, clamp_max(network.bytes_in, 5), network.bytes_in / 100)
| KEEP full_clamped_cost, @timestamp
```
