Creating your First Truth Table
Last Updated: 10/01/2018
Introduced in Version: 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.
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.
Name the truth table “Calculate Car Rental Cost” and click CREATE.
Begin the truth table configuration by specifying the input data the rule will evaluate. From the Properties panel, click on Show Editor for the Flow Input Data field.
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 Int32 as the type. Click OK.
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.
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.
Click on the [n/a] link next to the NumberOfDays header, and expand the Number Rules category. Click on Numeric Rules select Between and click Close.
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 edit (pencil) button under the NumberOfDays Between 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.
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.
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.
This completes the configuration of the truth table. Save and close, and test the outcomes using the Debugger.