Add an "Else If" to Expression bindings
b
brandon.keina
Add an "else if" option to expression bindings. Currently the only way to have multiple "If" statements in an expression is to have nested If statements.
Log In
M
Michael Flagler
Easiest method I've found is using case:
case(true,
a!=b, "error condition 1",
c < 17.4, "error condition 2",
isNull(d), "error condition 3",
"Unknown Condiiton")
Y
Yurika Iwase
ya agree, please just add else if and it will make our life so much easier!
J
Jonathan Swisher
I find using the coalesce function combined with the if statement is much easier to read than nested if statements. try this
coalesce(
if(a!=b,"error condition 1",None),
if(c < 17.4,"error condition 2",None),
if(isNull(d),"error condition 3",None),
,"Unknown Condition"
)
d
dan.bridgeman
Switch works well for some things, especially since it works for strings (which I think it didn't used to?). But there are cases where it would be even more cumbersome than the current "if" expression. I'm thinking of cases like:
if (a != b
, "error condition 1"
, if (c <17.4,
, "error condition 2"
, if (isnull(d)
, "error condition 3"
, "no error"
)
)
)
I don't see how using a "switch" would improve the above expression.
n
nick.minchin
dan.bridgeman:
I would write this as
if (a != b, "error condition 1"
,if (c < 17.4, "error condition 2"
,if (isnull(d), "error condition 3"
,"no error")))
Carl Gould
Have you tried the "switch" expression?