These docs are for v1.0. Click to read the latest docs for v1.2.

CLAMP

Limits a value to a specified minimum and maximum value range. If the specified value is below the minimum value or above the maximum value, the minimum value or maximum value, respectively, is returned.

Syntax

=CLAMP(value, min, max)

Arguments

ArgumentTypeDescription
valueNumberThe value to clamp
minNumberThe minimum value
maxNumberThe maximum value

Examples

=CLAMP(3.14159, 0, 10)3.14159
Restricts the value 3.14159 to the range 0 - 10

=CLAMP(-3.14159, 0, 10)0
Restricts the value -3.14159 to the range 0 - 10

=CLAMP(3.14159, 0, 1)1
Restricts the value 3.14159 to the range 0 - 1

=CLAMP(3, 1.5, 2.5)2.5
Restricts the value 3 to the range 1.5 - 2.5

=CLAMP(1, 1.5, 2.5)1.5
Restricts the value 1 to the range 1.5 - 2.5

=CLAMP(2, 1.5, 2.5)2
Restricts the value 2 to the range 1.5 - 2.5