@rdb , sorry I have to strongly contradict you there regarding the cosmetic issue. That’s just for speeding up the fix by providing my findings.
Originally, I wanted to point out that an empty output instead of the integer 0 will cause confusion if that result is used in another formula. I would be tempted to use “isempty” to check for the seemingly empty cell, and you be very confused if it returned “false” because there was was a hidden 0 value in the cell.
However, that does not seem to be the case. Please verify this, but as it turns out, switch() seems to broken because it falls into the “default” output when one switch branch returns zero.
Here’s my test:
Intended behaviour:
- All consistent numerical outputs
- “Neutral” returns zero
- Empty cell returns -5
- Untreated values return -6
- Good = 1, Bad = -1
Reference formula with ifs
ifs(
isempty("Einfachauswahl"),-5,
{Einfachauswahl}="Good", 1,
{Einfachauswahl}="Neutral", 0,
{Einfachauswahl}="Bad", -1,
True(),-6
)
The same with switch()
, making sure that the output in consistently the integer type:
switch(
if(isempty("Einfachauswahl"),"dummyentryforempty",{Einfachauswahl}),
"Good", 1,
"Neutral", 0,
"Bad", -1,
"dummyentryforempty",-5,
-6
)
My conclusion: The switch result “0” crashes into the “default” option => Bug?
The whole analysis was somewhat muddled by the fact that @sango used a “string” default value, which resulted in the value not being displayed because the detected column type was “number”.
Which is easily tested with this formula
switch({Einfachauswahl},"Good", 1,
"Neutral", 0,
"Bad", -1,
"Default") & " forced into String"