Create Rules Using a Decision Table
Use a decision table to facilitate creating rules that contain many conditions. A
complex rule might be more readable in a decision table rather than in a text
rule.
After a record complies with all the conditions in a single row of a decision table,
the record passes. If the record does not comply with any row, it fails.
You can use a decision table to create rules on a worksheet or in a data domain.
-
On the right side panel of the worksheet Rules tab or domain
Rules dialog, click Decision
Table.
The Add Conditions dialog appears where you can enter column names or
column expressions, and an optional alias that would make the content of
this column expression easier to understand.
-
On the line under Column Expression, start entering the name of the
column on which you want to define a rule, then select the column name from the
list that appears automatically.
For example, enter Zi and select Zipcode of the
<domain_name> from the list of columns
that appears.
-
(Optional) If you want the rule condition to be on concatenated values of multiple columns,
enter + and the name of the next column.
-
(Optional) On the line under Alias, enter a name.
For example, if you specified FirstName of the <domain_name> +
LastName of the <domain_name> under
Column Expression, you might want to enter
FullName under Alias.
-
(Optional) To add another column for this rule, click Add
Column, and repeat steps 2 through 4.
-
Click Save.
The decision table appears with the column names across the top and empty condition cells in
the next row.
-
Now that you have created the decision table and defined the column conditions, you can
perform the following tasks:
-
Define a rule expression for each column condition
-
(Optional) Add or delete rows in the decision table
-
(Optional) Split a row in the decision table
-
Save the decision table rule after you have defined, changed, or deleted the rule
expressions.
| Option |
Description |
| For worksheet rules |
Click Save on the Create New
Rule dialog |
| For domain rules |
Click the Save icon in the upper right
corner |
-
For worksheet rules, click Save.
-
For domain rules, save the rule by clicking the
Save icon in the upper right corner.
-
You can now take one of the following actions:
For worksheet rules:
-
Click the Run All Rules icon on the right
bottom of the Rules screen to show the
number and percentage of records that failed each rule.
-
Click the Data Table icon in the top left
corner to return to the worksheet where you can define a filter
to show the records that passed or failed each rule.
Define Rule Expression for Each Column Condition
Define the condition for each column in the empty cell below the column name in the decision
table.
-
Click the empty cell below the first column name.
The column name with the default operator =
appears.
-
(Optional) To specify a different operator, delete the = and enter
the operator symbol or name. If you start entering the operator name, you
can select it from the suggestion list that appears automatically.
For example, enter is not and select is not equal
to from the suggestion list.
-
Enter the value you want to define for the rule.
If the column is a string data type, enter a value surrounded by single
quotation marks.
-
For each subsequent column in the decision table, repeat steps 1 through
3.
For example, to define a rule that says the Zipcode, State, and City must not be null,
specify the following three conditional expressions below each column
name in the
Decision Table:
| Conditions: Zipcode
|
State
|
City
|
|
is not equal to null
|
is not equal to null
|
is not equal to null
|
-
To edit the expression in a cell, right-click and select
Edit.
A window appears with a text line that allows you to see longer
expressions more easily.
For more information about rule expressions in decisions tables, see the SAP HANA Rules Framework - Rule Expression Language
Guide
.
Add or Delete Rows in Decision Table
-
To add a row in a decision table, you can click on the empty cell below the last row and
enter the operator and value.
-
Right-click the cell in front of a row in the decision table to select any
of the following options:
| Option |
Description |
| Cut Row |
Removes the row; right-click on another row to paste it there |
| Copy Row |
Copies the row; right-click on another row to paste it there |
| Delete Row |
Deletes the row from the decision table |
| Paste Row |
Pastes the row that you copied onto this row |
| Insert Copy Above |
Inserts the row that you copied above this row |
Split a Row in Decision Table
Use the split option in a decision table when you want to
define multiple conditions for the same value of the previous column in the
decision table.
For example, suppose you want to define the following rule conditions:
-
Customers in the state of California and the city of Santa Monica
must have a phone number and an email address
-
Customers in the state of California and the city of Los Angeles must
have a phone number
-
Customers in the state of New York and the city of New York must have
a phone number and an email address
-
Customers in the state of New York and the city of Albany must have
an email address
For this rule, you will define the following decision table to split the
row for State = 'CA' into two rows for the conditions on City. The empty cell
for Email in the second row for CA does not have a condition, which means it can
have any value, including null.
| Conditions: State
|
City
|
Phone
|
Email
|
|
= 'CA'
|
= 'Santa Monica'
|
is not equal to null
|
is not equal to null
|
|
= 'Los Angeles'
|
is not equal to null
|
|
|
= 'NY'
|
= 'New York'
|
is not equal to null
|
is not equal to null
|
|
= 'Albany''
|
|
is not equal to null
|
To split a row in a decision table, perform the following steps after you have
defined the column conditions:
-
Click in the empty cell of the first column and specify the operator and
value.
For the above example, enter 'CA' after the State of the
<domain_name> = operand and
operator that appear by default.
-
Right-click the cell after the first column, and select the Split
option in the menu that appears.
Note
If you are currently editing the cell, this menu will not appear when
you right-click the cell. Click outside of the cell to exit edit
mode.
In the above example, right-click in the empty cell for the City column
and select Split.
-
In the first cell of the first row in the split, specify the operator and
value you want to define for the rule.
In the above example, enter 'Santa Monica' after City of
the <domain_name> = that appears by
default.
-
For each subsequent column in the decision table, repeat step 3.
In the above example, specify the following conditions for the next two
cells:
-
For the second row of the split, repeat steps 3 and 4.
In the above example, specify the following conditions for the three
cells:
-
City of the <domain_name> = 'Los Angeles'
-
Phone of the <domain_name> is not equal to
null
-
Leave the Email cell empty to indicate it can have any value, including null.
For more information about rule expressions in decisions tables, see the SAP HANA Rules Framework - Rule Expression Language
Guide
.