Creating your First Truth Table

Last Updated: 07/29/2016 Introduced in Verision: 2.0

 

Truth tables are rules that compare the possible combinations of multiple inputs, allowing the user to arrive at different outcomes depending on the specific combination. A truth table can output a piece of data, or take action by calling a flow.

Example

This example will use a truth table to return a dollar amount for a car rental. The business rules for the company are:
  • 1-3 days does not offer a discount, and the car is $50 a day.
  • 4-6 days offers the car at $43 a day.
  • Anything 7 days and beyond is $40 a day.
Navigate to a Designer Folder, and click Create Rule > Create Truth Table.
Creating truth Table.
 
Name the truth table “Calculate Car Rental Cost” and click OK.
 name table
 
 
Begin the truth table configuration by specifying the input data the rule will evaluate. From the Properties panel, click on Add for the Flow Input Data field.
 add flow input
 
 
Since the rule will evaluate the number of days the customer wants to rent the car, the input data will be numeric type. Name the input “NumberOfDays” and specify Int16 as the type. Click OK.
 
 
 input_flow
 
Next, configure the output data. This is what the rule will return; by default, it is set to return a true/false boolean value based on the evaluation of the input data. In this example, we want the rule to return a dollar amount. Therefore, the Output Type value needs to be set to a numeric type (Double). Click on the Browse button for the Output Type field and select Double. Click OK.
 
 output
 
 
The rule is ready to be configured. The shaded top row in the table represents the criteria for the rule, and in the rows below go the values against which the input data will be evaluated. In the shaded top row of the table in the workspace, click on the [no anchor data] link, select NumberOfDays, and click Close.
 no achor data
 
 
Click on the [n/a] link next to the NumberOfDays header, and expand the Number Rules category. Click on Numeric Range Rule and click Close.
 between not numeric range!
 
 
This completes the configuration of the top row. Next, plug in the values for the number ranges and set the output dollar amounts in the Result column. Click on the [ignored] link under the NumberOfDays Numeric Range Rule header in the truth table.
 
 
 
In the IncludesEquals section, check the Value checkbox to set it to True. This means that when the number of days equals 1 or 3, the rule will find that criteria true.
 condition
 
 
Click Close. Click the [ignore] link under the Result column. Select Constant as the Mapping Type, and enter 50 in the Value field. Click Close.
 constant 50
 
 
The truth table is now configured so that if the number of days to rent the car is 1 to 3, the daily rate is $50.
 
Click add row link to add the next row. Build the next row following the same method. Set the numeric range for the days to be 4-6, and the daily rate at $45.
 
The last row is configured with a high upper limit. The dollar amount for this criteria is $40.
 last field
 
 
This completes the configuration of the truth table. Save and close, and test the outcomes using the Debugger.
Note in Decisions 3.5 and later “Debug” Rule has changed to “Test” Rule
 
TestRule Screenshot

Additional Resources