A Decision Table is a tabular representation of a set of related input and output expressions, organized into rules indicating which output entry applies to a specific set of input entries.
Decision Tables are supported by both the Decision and the Business Knowledge Model element types. They are denoted by the icon in the top right corner of the element on a diagram.
On a diagram, double-click on a Decision element or BusinessKnowledgeModel element.
The DMN Expression window is displayed, showing details of the selected element.
This image shows the DMN Expression window as it appears for a Decision Table.
A Decision Table consists of:
- The Table Hit Policy (C+, U, A, P and so on) that specifies how the rules are applied
- A list of rules (1, 2, 3, 4 and so on), where each rule row contains specific input entries and corresponding output entries
- A list of Input Clauses (under the blue headings), defined as expressions that generally involve one or more input values
- A list of Output Clauses (under the pink heading), defining the output corresponding to a specific set of inputs
- Optional annotations for each rule (under the green heading) which you can add through the window Toolbar
An Input Clause consists of an expression and an optional list of allowed values (the row just underneath the column headings). Very often, the expression is simply an unmodified input value; however, it could also be an expression involving more than one input value or perhaps a conditional statement such as 'Application Risk Score > 100'. The allowable values apply to the expression result rather than the input values used.
Each Output Clause consists of an identifier (a name) and again an optional list of allowed values for that clause.
The Decision Table should contain all the inputs - and only those inputs - required to determine an output.
In determining which rules are applied, the expressions defined in the Input Clauses are evaluated for the given inputs and the expression results are then used to find rules with matching input entries.
Where the DMN Expression window is not wide or deep enough to display all columns and rows, you can use scroll bars to access the hidden content, or drag the borders out to increase every column width. The 'Input' and 'Output' column widths are initially the same, but you can adjust each column width independently of the others, by dragging the column border either within the table or in the gray bar just below the tab names.
Toolbar for Decision Table Editor
When a Decision Table is selected, the features available in the DMN Expression window are accessed via the Toolbar at the top of the window, as shown:
For more details refer to the Toolbar for Decision Table Editor Help topic.
In the case of Business Knowledge Model (BKM) elements, parameters are used to pass input values supplied by the invoking element. The BKM's decision logic is evaluated using the input parameters and the result is returned to the invoking element. By default, a BKM element is created with two input parameters, 'Input 1' and 'Input 2'.
Click on the icon in the toolbar of the DMN Expression window to display the 'Edit Parameters' dialog.
Here you can change the parameter names, re-arrange the sequence, set their data types, create additional parameters or delete existing ones.
Right-click on the 'Hit Policy Indicator', then choose the desired Hit Policy from the pop-up menu. The various Table Hit Policies are described in detail in the Decision Table Hit Policy Help topic.
An Input Clause of a Decision Table is defined as an expression. Very often, the expression is simply an unmodified input value; however, it could also be an expression involving more than one input value or it could be defined as a conditional statement, such as 'Application Risk Score > 100'. The allowable values apply to the expression result rather than the input values used and, as such, the type of the values should match the type of the expression result.
Decision Tables are created with two default Input Clauses, 'Input 1' and 'Input 2'. The data type for both of these clauses is 'number'. In the DMN Expression window, the Input Clauses are displayed as column headings on the Decision Table. To modify an Input Clause, click on the column heading to select the cell, then click again or press to edit.
Auto-completion is supported when editing Input Clauses. That means, for Decision elements, any inputs that are connected to the Decision element are made available for selection from a list. Similarly, for Business Knowledge Model elements, the invocation parameters are made available for selection from a list. See the DMN Expression Auto-completion Help topic for further information.
To add additional columns of input entries to the Decision Table, click on the icon on the toolbar of the DMN Expression window.
To remove input columns from the table, right-click within the unwanted input column, then select the option 'Delete Input Column' from the pop-up menu.
The order of the input columns in the table can be re-arranged by dragging and dropping columns to new positions. (Drag the unlabelled cell at the very top of the table column to the required position.)
When defining an 'Input' or an 'Output' column, the second row of the column defines the Allowed Values. This is an optional cell in the column, but useful for clarifying the entries in the rows beneath it. When running a validation, each of the cells below the Allowed Values cell are checked to make sure they conform to the expression in this cell.
The expressions used in this cell depend on how the 'Input' or 'Output' column is typed. For example:
- Number - [18 ..35]
- String - 'High', 'Low', 'Medium'
- Boolean - true, false
- Undefined - '-'
Fast Fill Allowed Values
The Input/Output Expression that this references can be a simple value or a complex FEEL expression; however, if it is directly related to an ItemDefinition's 'Allowed Values' field then pressing the Spacebar will enable a fast-fill option to set the 'Allowed Values' as defined in the ItemDefinition (usually referenced via an InputData element).
Fast Fill Rows
Once the 'Allowed Values' field is defined, as well as restricting the values that can be used when defining the rules in the table, the 'Allowed Values' field also provides the user with a fast fill option. This is invoked, in a rule cell, by pressing the Spacebar and selecting the required item:
For more details see the Help topic DMN Expression Auto Completion.
An Output Clause consists of a name, a data type and an optional list of allowed values. To modify an Output Clause, click on the column heading cell to select the cell, then click again or pressto edit.
To add additional columns of output entries to the Decision Table, click on the icon on the toolbar of the Expression editor window.
To remove Output columns from the table, right-click within the unwanted Output column, then select the option 'Delete Output Column' from the pop-up menu.
The order of the columns in the table can be re-arranged by dragging and dropping columns to new positions. (Drag the unlabelled cell at the very top of the table column to the desired position.)
Data Type for Input/Output Clauses
For the simulation to work it is critical to set the data type for all Input and Output Clauses. Range, gap and overlap validations are supported for clauses of type 'number', but validation cannot be performed if the type has not been specified. Code Generation for typed languages such as C++, C# and Java requires that the data types are specified. When the data type is specified as 'string', there is no need to enclose each string literal within quotes. String values are displayed using italic font if the type has been declared.
To set the data type, right-click on the Input or Output column header and select the required type from the list.
Defining Decision Table Rules
Decision Table rules are defined by specifying input entries and corresponding output entries within the cells of a table row. For 'number' data types, input entries can be specified as a single value, or as a number range, such as '<10', '>100' or '[2..8)'. (When defining number ranges, the use of round brackets indicates that the bounding number is NOT included; use of square brackets indicates the bounding number is included.) Output entries should specify a single value per cell.
Additional rules can be appended to the list of rules by clicking on the icon in the toolbar. Unwanted rules can be deleted from the table by right-clicking on the rule and selecting the option 'Delete Rule Row' from the pop-up menu.
Existing rules can be copied and pasted within the table by first selecting the rules, (use 'Ctrl+Click' to add/remove from selection), then using the menu options 'Copy Rules to Clipboard' and 'Paste Rules from Clipboard' to perform the copy and paste. The copied rules can then be modified by selecting and editing individual cell entries.
If the 'Allowed Values' field is set for a string or Boolean expression, thecan be used to display a list of values to select from, as shown in the earlier Allowed Values - Fast Fill Rows section.
Rules can also be sorted within the table, either by:
- Clicking the icon on the toolbar, then choosing to either 'Sort By Input' or 'Sort By Output', or
- Right-clicking on individual rules within the table and selecting the 'Move Rule Up' or 'Move Rule Down' option from the pop-up menu
To determine which table rows are selected for output, the expressions that are defined by the Input Clauses are evaluated for the given inputs and the results of the expressions are then compared against the input entries of the table rows. Where the expression results match the input entries of a table row, that row is selected for output.
The Decision Table's 'Hit Policy' determines how the table's matching rows are then used to produce its output.
You can select - using a Toolbar icon - to display the Decision Table in one of three formats, as shown here.
Rule-as-Row format, where the rule is developed along rows with the inputs, outputs and annotations set in columns:
Rule-as-Column format, where the rules are developed down columns with the inputs, outputs and annotations set along the rows:
Rule-as-Crosstab format, where the rules are formed from inputs defined as a set of rows AND a combination of columns, with outputs set in the intersecting cells. (Note that this format hides the 'Annotation' fields):
At the end of a simulation, in a Crosstab Decision Table, related input entries and output entries are highlighted. For example, in this simulation processing resulted in the output of a 0.10 discount for a Business Customer where Order Size was less than or equal to 10 and delivery was not applicable.
In Rule-as-Crosstab format, as the inputs form both rows and columns and the outputs are at the intersections, the steps for setting values are slightly different from those for the other two formats.
- To add another type of input, right-click on the input column header and select the 'Add Input' option. You are prompted to enter the input name; the input is added as a set of fields under the current column fields.
To delete an input type from the columns, right-click on its set of fields and select the 'Delete Input' option. The name of the input and its set of fields are removed from the column headings.
- To add another type of output, right-click on the Output block in the top left of the window and select the 'Add Output' option. You are prompted to enter the Output name; the name is added to the Output block and a new row is added to each cell in the body of the window.
To delete an Output type, right-click on the type name in the Output block in the top left of the window and select the 'Delete Output' option. The Output name and its fields in the grid are removed.
- You can rotate between the input types to select one for the row headers. Right-click on the row and click on the 'Select Input as Row Header' option. This displays a list of the input types; click on the type to use as the row header; the other types are combined in the columns.
- To add a value entry row or column to the inputs, right-click on a current row or column and select the 'Add Input Entry Row' or 'Add Input Entry Column' option, as appropriate. A prompt displays for the name of the input entry; when you enter this, the appropriate row or column is added to the Decision Table.
To delete a value entry row or column, right-click on it and select the 'Delete Input Entry Row' or 'Delete Input Entry Column' option. The selected row or column is deleted from the table.
- In the Input columns, each row matches a type of input. If you want to move the row for one type of input above or below another, right-click on it and select the 'Move Input Up' or 'Move Input Down' option. The context menu only provides the options that can be actioned, so as it is not possible to move, say, the last row downwards, the 'Move Input Down' option is not listed.