Case expression – choosing between several values¶
The case expression returns the value of the first condition that applies – like "if … else if … else" in a formula. It is the tool for every value that depends on a situation: a colour per priority, a text per status, a fallback for an empty field.
1. At a glance¶
| Purpose | Checks conditions in order and returns the value of the first one that is true |
| Typical use | Colour or icon depending on the status, a label per category, a fallback value |
| Returns | The value of the chosen branch, with its type |
| Related | Logical (the conditions), rule Conditional of Modify Value (exactly two outcomes) |
2. Settings¶
| Setting | Meaning | Default |
|---|---|---|
| Cases ("If", "Else If") | A list of branches, each with a condition and a "Return" value. "Add case" adds a branch. | – |
| "Condition" | An expression that returns yes/no – usually a logical expression | – (required) |
| "Return" | The value returned when the condition is true | – (required) |
| "Default" | The value returned when no condition is true (the "else") | empty |
The menu of a branch ("More") offers "Move up", "Move down" and "Show condition" / "Hide condition", which displays a logical condition read-only below the branch.
3. Behaviour¶
- The branches are checked from top to bottom.
- The first branch whose condition returns true (
trueor1) wins; its "Return" value is evaluated and returned. Later branches are not checked. -
If no condition is true, "Default" is returned. Without "Default", the result is an empty value.
-
Any other result of a condition – a text, a number other than 1, an empty value – counts as false.
- A branch without a condition never applies.
- A branch whose "Return" is empty returns an empty value.
Put the most specific condition first. A general condition at the top hides all branches below it.
4. Examples¶
Colour per priority:
| Branch | Condition | Return |
|---|---|---|
| If | "Priority" Equals Critical |
#D32F2F |
| Else If | "Priority" Equals High |
#F57C00 |
| Default | – | #757575 |
Fallback for an empty field: If "Contact person" Empty → Return the field "Customer name";
Default → the field "Contact person".