Conditional Formulas

Conditional formulas are a way to test for truthinessopen in new window or falsinessopen in new window of variables or comparisonsopen in new window and return a different value according to this.

if

if takes 3 arguments, in order:

  • condition the variable or comparison to test truthiness on
  • value1 the value to return if the condition is truthy
  • value2 the value to return if the condition is falsy

Example

Here, we're using the if formula with a variable (display modal) as a condition. The formula will test if the varibale is true, and because it's false in this case, it'll return the second value.

ifEmpty

not

The not formula takes a variable or camparison, and return the opposite booleanopen in new window value.

Ok, so what does it means? 😆

If a variable or comparison is truthy, it will return false. If a variable or comparison is falsy, it will return true.

So, this formula is useful when you need to invert a condition.

Example

In this example, we apply not to the display modal from before, which is false. So the return value is true.

If we take back the example from the if formula, it will now return the first value as the comparison is now not(false), so true.

switch

The switch formula takes an expressionopen in new window, then checks its equality with each value and return the matching result.

Example

Here, switch takes the variable user location as a an expression, which equals to "USA". It'll then loop over values, match the one which equals "USA" too, and return the matching value, which is Hello from the US 👋".

Last Updated:
Contributors: Joyce Kettering