Bommer supports conditional statements in formulas in the form of if <conditional> then <VALUE1> else <VALUE2>. Here is a demonstration and explanation of the statement structure:

```
= if ("PROPERTY1" == VALUE1) then "PROPERTY2" else if ("PROPERTY1" == "VALUE2") then "PROPERTY3" else 0
```

The way this is broken up is as follows:

- As usual, the equal sign (=) at the beginning marks this as a formula in Bommer
- After the = you start this with the new reserved word
`if`

. This is what starts the conditional. - After the if is the “conditional test”, which is wrapped in parentheses. This test can use any Bommer formula operator or operand, and must evaluate to true or false.
- In this case, we are comparing the value we are comparing the value of the Bommer property “PROPERTY1” to some fixed value using the double equal sign (==) operator. If this is true, it will proceed to the next part of the statement marked by
`then`

; if it is false, it will skip to the`else`

.- In the above statement this leads to returning PROPERTY2 if the value of PROPERTY1 is VALUE1

- The next part is including the
`else`

portion of the formula. In this case, we are nesting a conditional formula to check “PROPERTY1” against a different fixed value. If PROPERTY1 contains VALUE2 then it returns the value of PROPERTY3 instead. - At the end of this we have the else conditional to cap the formula off with a default value, if neither of the previous conditions returned true. In this formula, that value is 0: this means that if PROPERTY1 does not match VALUE1 or VALUE2, it will return 0 in this case.

You can also include other conditional statements within these formulas to have more complex formulas in Bommer. See our full formula guide for more info on how to do this, or see our example formulas guide for examples of common formulas using conditional statements. You can also check out our migration guide for info on how to enable this functionality for existing designs.

## Comments

0 comments

Please sign in to leave a comment.