SWITCH
Usage
Use this function to get a result from a list of cases, comparing them with a given value. You can use as many =CASE (or =CASES) functions as you need and provide a =DEFAULT function value too.
Category | Function | Type | Where to use | Argument statement |
---|---|---|---|---|
FUNCTION | SERVER ROW | CONDITIONAL | .VALUE |
Syntax
1 2 3 4 5 6 7 |
|
Arguments
Value_To_Check
any cell value (#Storage_Name.Field_Name.VALUE
or .OLDVALUE
), constant, System Variables or function-returned value
Case_N
any value used to compare the Value_To_Check argument
Cases_List_N
a list of values used to check if the Value_To_Check is in
Result_N
any cell value (#Storage_Name.Field_Name.VALUE
or .OLDVALUE
), constant, System Variables or function-returned value
Default_Value
any cell value (#Storage_Name.Field_Name.VALUE
or .OLDVALUE
), constant, System Variables or function-returned value
Note
This function is mainly used as argument in SERVER FUNCTION such as EQ, NEQ, ... It can be used also in CLIENT FUNCTION such as CELLEQ, CELLNEQ, ... if the arguments are not depending on any record's fields value
Return Value
Value
Examples
Example 1
Formula
=SWITCH(#StorageExample.Status.VALUE;
=CASE(2; "Submitted");
=CASE(3; "Approved")
=CASE(4; "Rejected")
=DEFAULT("Draft")
)
Description
Formula checks if the cell values of the field Status in the StorageExample match value 2 then return Submitted, else if match value 3 then return Approved, else if match value 4 then return Rejected else return default value Draft
Result
Draft, Submitted, Approved or Rejected
Example 2
Formula
=SWITCH(#StorageExample.Status.VALUE;
=CASE(2; "Submitted");
=CASE(3; "Approved")
=CASES(4; 5; 6; "Rejected")
=DEFAULT("Draft")
)
Description
Formula checks if the cell values of the field Status in the StorageExample match value 2 then return Submitted, else if match value 3 then return Approved, else if match value 4 or 5 or 6 then return Rejected else return default value Draft
Result
Draft, Submitted, Approved or Rejected