An If-Then-Else expression is a logical notation that evaluates a test statement. It executes a primary expression if the test is true and a secondary expression if the test is not true. You can also introduce additional test statements using the Add Else If button.
- Click Add new decision in the Decisions bar and select If-Then-Else from the Create Decision window. See Adding and Ordering Decisions.
- In the if expression field, press Ctrl+Space to view an auto-suggest menu. You can use any decision outputs, variables, functions, and keywords listed in the menu to define expressions in if, then, and else fields. Use the FEEL syntax to define expressions. See Understanding FEEL.
- If necessary, change the logical notations for then and else fields to create a nested logic. All fields have the expression notation selected by default. Click Change body and select a different notation from the available options for a particular field. Configure logic for the selected notation.
- Additionally, you can cut or copy a notation from one field and paste it into another field using options available in the Change body menu.
- After the decision logic is complete, click Save to save and validate changes manually. Changes you make within the decision model are also automatically saved and validated from time to time. Errors, if any, are displayed within the decision.
In the following example, the input value of temperature determines the output of the If-Then-Else decision:
Description of the illustration dmn-ifelse.png
The following example uses an additional test statement, precipitation > 50, through Else If to determine the final output:
Description of the illustration dmn-ifelse2.png