CLAMP

Description

CLAMP ensures a numeric value stays within a specified range. If the value is below the minimum, the minimum is returned. If it is above the maximum, the maximum is returned. Otherwise, the value itself is returned unchanged.

Syntax

CLAMP(value, min, max)

Returns: A number within the range [min, max].

Example

p is Person
CLAMP(p.age, 18, 65)

If the person's age is 12, this returns 18. If it is 70, this returns 65. If it is 40, this returns 40.

Last updated

Was this helpful?