# CLAMP_MAX

The CLAMP_MAX function restricts all input sample values to a specified upper bound. Any value above the defined maximum is set to the maximum value.

## Syntax

`CLAMP_MAX(field, max)`

### Parameters

#### field

The field whose values you want to clamp.

#### max

The upper bound to which values are clamped.

## Examples

Calculates the sum of network costs after clamping values to specified minimum and maximum bounds, grouping results by one-minute time buckets.

```esql
TS k8s
| STATS full_clamped_cost=sum(clamp(network.cost, 1, 2)), clamped_cost=sum(clamp_max(network.cost, 1)), clamped_min_cost=sum(clamp_min(network.cost, 10)) BY time_bucket = bucket(@timestamp,1minute)
```