ESCOLHER(value; case1; res1; ...; default?) — also accepts the name CASO.
| Field | Value |
|---|---|
| Category | Logic |
| Type | Scalar (operates value by value) |
| Arity | 3 or more arguments |
| Compiles to SQL (calculated column) | Yes |
| Version | Formula engine v3. |
Aliases#
Canonical name: ESCOLHER. Accepted aliases (case-insensitive): switch, caso.
Syntax#
code
ESCOLHER(expr; arg2; arg3; …)All arguments are expressions.
Returns#
The result of the matching case, or the default.
Null handling#
Blank is treated as false (spreadsheet rule: 0 and blank text are false).
Evaluation context#
Scalar — evaluated on the result of the arguments (in calculated columns, it runs row by row).
Differences from DAX#
- DAX equivalent: SWITCH
- Compatibility: Compatible with DAX
- Note: SWITCH(value; case; result; …; default). Alias CASO.
Examples#
code
ESCOLHER(uf; "SP"; 1; "RJ"; 2; 0)Example with values#
Input: selection = 2.
code
ESCOLHER(2; 1; "um"; 2; "dois"; "outro") → "dois"Expected result: "dois"
Business example#
Apply a business rule — customer tier, order status, target hit or missed.
Common errors#
Typos in a column name, an incompatible type, or an invalid argument become a friendly message (pt-BR) — the engine never silently returns a wrong number.