What's the difference between Switch and SwitchIf?

I’ve always used Switch when i’ve coded on Java/JavaScript/etc, but here, i’ve tried to use Switch as usual and it didn’t work as usual, but SwitchIf does, and after reading what it’s supposed to do, i didn’t understood it.

Could someone ELI5?

Hi @Pedro_Jimenez ,

are you familiar with the formula documentation? It’s explained there.

In SwitchIf, every “argument pair” needs a condition first that is either true or false.

Switch on the other hand has an expression, like a variable, as a first parameter followed by the “argument pairs”. Each argument pair starts with a value, if this value matches the expression, the condition is true.

1 Like

SwitchIf is like if else if else... Use it instead of nested If(expr1, ifTrue1, If(expr2, ifTrue2,...))
Switch is take an input and compare it strictly to values. Use it e.g. for returning different things depending on a dropdown value (e.g. [Task status].Switch("Done", ...))

JS CFL
image image

And

Value.Switch(
  "val1", do1,
  "val2", do2
   ...
)

is like

SwitchIf(
  Value = "val1", do1,
  Value = "val2", do2
  ...
)
2 Likes

Hi @Paul_Danyliuk @M_Schneider

Thanks for your replies, i felt so confused that i couldn’t think clearly! But now it’s clear, thanks for the help!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.