On This Page

Conditional Functions

Functions for conditional evaluation, comparisons, and logical operations.

Common Patterns

  • Simple Categorization:

    if(Amount > 1000, "High", "Low")
  • Multi-Level Categorization: Nest if functions for multiple categories:

    if(Amount >= 10000, "Enterprise",
       if(Amount >= 1000, "Business",
          if(Amount >= 100, "SMB", "Consumer")
       )
    )
  • Using the Bucket Function: For numeric thresholds, bucket is often cleaner:

    // Auto-generated labels
    bucket(Amount, 100, 1000, 10000)
    // Result: "<100", "100–1K", "1K–10K", or "≥10K"
    
    // Custom labels
    bucket(Amount, 100, "Small", 1000, "Medium", 10000, "Large", "Enterprise")
  • Time-Based Conditions:

    if(dayOfWeek(StartTime) in [6, 7], "Weekend", "Weekday")

if

(condition, thenValue, elseValue)

Returns one value when a condition is true and another when it is false.

Parameters
condition boolean The condition to evaluate
thenValue any Value to return if the condition is true
elseValue any Value to return if the condition is false
Returns any
Examples
if(Amount > 1000, "High", "Low") High or Low
if(Status == "Approved", 1, 0) 1 or 0
if(5 > 3, "yes", "no") yes
if(2 > 7, "a", "b") b
Notes

Can be nested for multiple conditions.

min

(value1, value2, ...?)

Returns the smallest value from a list of numbers.

Parameters
value1 number First value
value2 number Second value
... (optional) number Additional values, up to 6 total
Returns number
Examples
min(5, 3, 8, 1) 1
min(Amount, Budget) smaller of the two
See Also
max

max

(value1, value2, ...?)

Returns the largest value from a list of numbers.

Parameters
value1 number First value
value2 number Second value
... (optional) number Additional values, up to 6 total
Returns number
Examples
max(5, 3, 8, 1) 8
max(Amount, MinimumAmount) larger of the two
See Also
min

bucket

(value, thresholds...)

Categorizes a value into buckets based on thresholds. Supports automatically generated or custom labels.

Parameters
value number The value to categorize
thresholds... number | string Threshold values, optionally followed by labels
Returns string
Examples
bucket(Amount, 100, 1000, 10000) <100, 100–1K, 1K–10K, or ≥10K

Automatically generated labels

bucket(hour(StartTime), 6, "Night", 12, "Morning", 18, "Afternoon", "Evening") Night, Morning, Afternoon, or Evening

Custom labels

bucket(500, 100, 1000, 10000) 100–1K
bucket(14, 6, "Night", 12, "Morning", 18, "Afternoon", "Evening") Afternoon
Notes

In auto mode, all arguments after the value must be numbers. In manual mode, provide threshold/label pairs followed by a default label.