OpenRules Decision Tables

In this post I will summarize the most popular decision tables supported by OpenRules. All OpenRules tables start with a keyword in the top left corner:

  • DecisionTable or DecisionTableSingleHit
  • DecisionTableMultiHit
  • Decision or DecisionTableSequence

Simple Decision Tables

Let’s consider how to represent business logic for decision model “Vacation Days“:

This singe-hit decision table describes business logic for eligibility for extra 5 days:

Similarly we may describe business logic for eligibility for extra 3 and 2 days:

To combine these rules with respect to the basic 22 days and incompatibility of extra 5 and 2 days, we may use this multi-hit decision table:

First, this table will unconditionally assign 22 to the decision variable “Vacation Days”. Being a multi-hit table, it will continue to execute other rules by adding 5, 3, and/or 2 days when the proper conditions are satisfied.

Decision tables execute their rules in top-down order. Singe-hit tables stop rules execution after they hit the first rule which conditions are satisfied. Multi-hit tables execute all rules which conditions are satisfied.

All these tables use keywords “Condition” and “Conclusion” in the second rows. You also may use their synonyms: Condition=If and Conclusion=Action=Then. All conditions are connected by the logical “AND“, e.g. the last rule in the above table “CalculateVacationDays” will be executed only when both the first and the third conditions are satisfied. You may use multiple conclusion columns but they also will be connected by the logical “AND“.

If you want to add an OR-condition, you simply add another rule. All above rules inside decision tables are connected by the logical “OR”.

Default Values

Note that in a single-hit table the default value is usually defined by the last rule. For instance, all the above singe-hit decision tables use FALSE in the last row as the default when previous rules are not satisfied.

Contrary, in a multi-hit table the default value is usually defined by the first rule. For instance, the multi-hit table “CalculateVacationDays” uses 22 in the first row as the default value for Vacation Days, and all consecutive rules (if satisfied) may change this value.

Operators in Separate Sub-Columns

The above tables use operators in the expressions as < 18 or >= 60. But you also may put operators in special sub-columns like below:

Note that in such cases the title cells such as “Conditions” and “Age in Years” should be merged. By the way, in the very first row all cells are always merged.

There are many predefined operators like Is, Is Not, Is One Of, Is Not One Of, Incudes, Add, etc. – see User Manual p. 36.

Sequential Decision Tables

There is one more type of decision table called “Sequential” and defined by the keyword “DecisionTableSequence” or simply “Decision“. These tables are similar to multi-hit decision tables with one important difference:

  • DecisionTableMultiHit first evaluates conditions of all rues and then executes only satisfied rules. It means already executed rules cannot affect the execution of the rules below them.
  • DecisionTableSequence executes satisfied rules one-by-one without their preliminary evaluation. It means executed rules can affect the execution of the rules below them. It works more like a sequence of traditional programming statements. For example, consider a situation when the first rule may change a decision variable used in a condition of the second rule. It means the execution of the second rule depends on the execution results of the first rule.

Here are a few examples. Look at this table of the type “Decision”:

The first rule executes a sub-decision “DecisionValidate” that defines the decision variable “1040EZ Eligible”. The second sub-decision “DecisionCalculate” will be executed only when 1040EZ Eligible is TRUE. The following sequential decision table determines a maximum of 3 dates:

Summary

OpenRules offers 3 types of decision tables: DecisionTable, DecisionTableMultiHit, and Decision. Used in Excel, they provide business users with a very powerful while intuitive way to represent their business logic. OpenRules customers rely on many predefined types of conditions and conclusions with various operators described in the User Manual. At the same time, they may easily add new domain-specific conditions and conclusions to make the representation of their business logic even more intuitive.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.