CLAMP

Returns the value if it is between minimum and maximum or return minimum/maximum if the value is lesser/greater than minimum/maximum

Usage

CLAMP(minimum, value, maximum)

Parameters

minimum

(Required) The minimum number to return

value

(Required) The number to limit

maximum

(Required) The maximum number to return

Examples

Example With these variables Result

CLAMP(0, my_value, 100)

my_value is 10.5

10.5

CLAMP(0, my_value, 100)

my_value is -4

0

CLAMP(0, my_value, 100)

my_value is 107.5

100

More information

CLAMP is equivalent to MAX(minimum, MIN(maximum, value)), but is more intuitive.

Reminders

A text containing digits is not handled as a number. To have an actual number:

  • use the @NUMBER_QUESTION to set the variable
  • write a numeric value directly in the code without quotes, ex: age >= 18
  • use a function which converts to a number: NUMBER(text_containing_numbers)
  • use a function which returns a number: FIND("world", "hello everybody")

See also