Skip to content

BAND

Info

New in Atfinity 18.

Description

BAND returns the label of the band a number falls in. It replaces a chain of if and elif that compares a number against one limit after another.

Syntax

BAND(value, thresholds, labels)
  • value: the number to place. A number with a unit is compared by its number
  • thresholds: the limits between the bands, in strictly ascending order
  • labels: one label per band, so one more than there are thresholds. A label can be a text, an option key or a number

A value below the first threshold gets the first label, and a value equal to a threshold gets the label of the band above it. An unknown value returns unknown. A label count that does not fit the thresholds, or thresholds that do not ascend, fail the rule with a case error.

Example

p is Person
BAND(p.risk_score, [6, 8, 11, 14], ['very_low', 'low', 'medium', 'high', 'very_high'])

A risk score of 5 returns 'very_low', 6 and 7 return 'low', and 14 or more returns 'very_high'.

With numbers as labels, ADD_MONTHS(p.last_review_date, BAND(p.risk_score, [8, 14], [36, 24, 12])) sets the next review 36 months after the last one below a score of 8, 24 months from 8 and 12 months from 14.