Rows and cells

In a decision table, the values in the cells of a row define the conditions and actions of a rule.

You create a rule by adding a row to a table, and entering values in the cells for conditions and actions. When you run the rules in a decision table, the decision engine typically runs the rules row by row, from the first row to the last row. no matter the execution mode (RetePlus, sequential and Fastpath).

However, the order the rules run can change if a decision table has a definition bound to the working memory or a generator. For Fastpath and sequential, the decision engine first runs all the lines for the first object in the working memory, and then passes to the next object. With RetePlus, the engine runs all the lines for all the objects that are sorted by row number from line 1 downward.

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A 100,000 300,000 true 0.001
2 A 300,000 600,000 true 0.003
3 B 600,000 900,000 true 0.005

Partitions

You can group a set of consecutive rows that have the same value for a given condition. In this case, the cells to the right of the grouped values are part of the same partition. All cells in the first column of the table belong to the same partition by default.

Note: If you are using the editor with right-to-left orientation, the partition consists in the cells to the left of the grouped values.

In Rule Designer, you group cells by merging them.

In the following table, the Grade A cells of rows 1 and 2 are grouped into one cell. As a consequence, the cells that correspond to the amount of the loan become part of the same partition.

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A 100,000 300,000 true 0.001
2 300,000 600,000 true 0.003

You read the two rules as follows:

  • Rule 1

    if
       all of the following conditions are true:
          - the loan grade is A
          - the amount of loan is between 100000 and 300000
    then
       - set the insurance required to true
       - set the loan rate to 0.001
  • Rule 2

    if
       all of the following conditions are true:
          - the loan grade is A
          - the amount of loan is between 300000 and 600000
    then
       - set the insurance that is required to true
       - set the loan rate to 0.003

A partition cannot be derived solely based on the fact that rows have the same a value. In the following table, we added a row that has the same value for the grade as the other rows. Because its value for the grade is not grouped with the others, it creates a new partition for the amount of the loan and the existing partition remains the same.

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A 50,000 100,000 false 0.001
2 A 100,000 300,000 true 0.001
3 300,000 600,000 true 0.003

The following example shows a bigger table with several partitions. Cells A and B in the Grade column each have a partition of cells in the Amount of loan column. It means that if a loan request has an A grade, one of rules 1 - 4 might apply depending on the amount of the loan. Here, for example, the possible values for the amount are partitioned into the following ranges: equal to or less than 100000, 100000 - 300000, 300000 - 600000, and more than 600000. These ranges are tested in the cells on the right of grade A.

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A < 100,000 false
2 100,000 300,000 true 0.001
3 300,000 600,000 true 0.003
4 ≥ 600,000 true 0.005
5 B < 100,000 false  
6 100,000 300,000 true 0.0025
7 300,000 600,000 true 0.005
8 600,000 800,000    
9 ≥ 600,000 true 0.0075

Each numbered row in the table still forms a rule. Partitioning helps you compare rules with similar conditions, and find overlaps and gaps between values of the rules.

In condition columns, you can change the operator for certain cells. The column might be defined with a is between <min> and <max> operator, which you use for most of the rows, and you might override this operator for the last row of a partition to match all the remaining values with a more than <min> operator. Because these operators do not need the same number of parameters, the column may show a different number of subcolumns depending on the row.

Empty cells

A row can contain empty cells. If an empty cell is in a condition column and there is at least one condition in the row, the condition that is associated to the empty cell is ignored. In this case, the next cell or partition on its right, if any, is evaluated. If a row contains only empty cells in the condition columns, the rule is not applicable and the entire row is ignored, even if there are actions in the action columns.

The following table illustrates different rows that contain empty cells:
  • In row 3, the decision is based on the grade and on the duration of the loan. The amount of the loan is ignored.
  • In row 4, the decision is based solely on the grade.
  • Row 5 is ignored because it contains no condition.
  Grade Amount of loan Duration of loan Insurance required Insurance rate
Min Max
1 A 100,000 300,000 12 true 0.001
2 A 300,000 600,000 24 true 0.003
3 A   12 true 0.008
4 B       true 0.004
5         false 0.005

If an empty cell is in an action column, the action cell is ignored. In the following table, the first rule does not set an insurance rate.

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A < 100,000 false
2 100,000 300,000 true 0.001
3 300,000 600,000 true 0.003
4 ≥ 600,000 true 0.004

Otherwise cells

You can use an Otherwise cell to collect all the values that are not already covered in a partition.

The behavior of otherwise cells can change in the presence of empty cells. Using both otherwise and empty cells in the same partition is not recommended because it might create overlaps and make the table difficult to understand.

The meaning of otherwise cells follows these principles:
  • If a partition contains an otherwise cell and cells with values, the otherwise cell applies to values that are not already covered by other cells in the partition.
  • If a partition contains an otherwise cell, empty cells, and cells with values, the rows with empty cells before the first value are evaluated first, all the cells with values second, and then the otherwise cell is evaluated. Finally, the empty rows after the first cell with a value are evaluated after the otherwise.
  • If a partition contains an otherwise cell and no other cell, the otherwise cell becomes irrelevant and is ignored.
  • If a partition contains an otherwise cell and all its other cells are empty, the otherwise cell becomes irrelevant and is ignored.

In the following table, the Otherwise cell collects all the values before 100000 and after 600000:

  Grade Amount of loan Insurance required Insurance rate
Min Max
1 A 100,000 300,000 true 0.001
2 300,000 600,000 true 0.003
3 Otherwise true 0.004

You read the three rules as follows:

  • Rule 1

    if
       all of the following conditions are true:
          - the loan grade is A
          - the amount of loan is between 100000 and 300000
    then
       - set the insurance required to true
       - set the loan rate to 0.001
  • Rule 2

    if
       all of the following conditions are true:
          - the loan grade is A
          - the amount of loan is between 300000 and 600000
    then
       - set the insurance that is required to true
       - set the loan rate to 0.003
  • Rule 3

    if
       all of the following conditions are true:
          - the loan grade is A
          - it is not true that the amount of loan is between 300000 and 600000
    then
       - set the insurance that is required to true
       - set the loan rate to 0.004

The third row is the last row applied. If rows 1 and 2 don't match the conditions, the third rule is run and the rate of the insurance is set to 0.004.

Otherwise with empty cells

This section contains two tables with the same contents to show the order in which the rows are evaluated.

In the first table, the Grade column has a mix of rows that contain nothing (empty), values, and the Otherwise condition:

  Grade Amount of loan Insurance required Insurance rate
Min Max
1     ≤50,000 false
2 A   < 100,000 false
3 A 100,000 300,000 true 0.001
4 A 300,000 600,000 true 0.003
5 B   < 100,000 false
6 B 100,000 300,000 true 0.003
7 B 300,000 600,000 true 0.005
8     ≥600,000 true 0.008
9 Otherwise 100,000 300,000 true 0.05
10 Otherwise 300,000 600,000 true 0.07
11 C   < 100,000 true 0.004
12 C 100,000 300,000 true 0.006
13 C 300,000 600,000 true 0.006
14 C   ≥600,000 true 0.015
15     ≥600,000 true 0.016
The rows are processed in the following order based on the contents of the cells in the Grade column:
  1. Row 1, which is empty. Empty rows before the first row with a value are evaluated first.
  2. Rows 2-7 and rows 11-14, which contain the values A, B and C®.
  3. Rows 9 and 10, which contain the Otherwise condition.
  4. Rows 8 and 15, which are empty. They are evaluated after the rows with values in their order of occurrence, so row 8 before row 15.

The following table shows the order in which the rows in table 1 are evaluated:

  Grade Amount of loan Insurance required Insurance rate
Min Max
1     ≤50,000 false
2 A   < 100,000 false
3 A 100,000 300,000 true 0.001
4 A 300,000 600,000 true 0.003
5 B   < 100,000 false
6 B 100,000 300,000 true 0.003
7 B 300,000 600,000 true 0.005
11 C   < 100,000 true 0.004
12 C 100,000 300,000 true 0.006
13 C 300,000 600,000 true 0.006
14 C   ≥600,000 true 0.015
9 Otherwise 100,000 300,000 true 0.05
10 Otherwise 300,000 600,000 true 0.07
8     ≥600,000 true 0.008
15     ≥600,000 true 0.016