ExCellerate.Functions.General.Ifs (excellerate v0.4.0)

Copy Markdown View Source

Evaluates a series of condition/value pairs and returns the value for the first truthy condition.

Arguments must be provided in pairs: condition1, value1, condition2, value2, .... Use true as the final condition to provide a default. Returns null if no conditions are met.

Examples

ifs(score > 90, 'A', score > 80, 'B', true, 'C')
   'A' (when score is 95)
   'B' (when score is 85)
   'C' (when score is 70)

ifs(x > 10, 'big', x > 5, 'medium')
   null (when x is 1)