Skip to main content
This guide walks you through creating a decision table for a shipping charges calculation system. This approach is ideal for business rules that need to be managed by business analysts and subject matter experts without requiring programming knowledge.

Example Use Case: Enterprise Shipping Charges

Our enterprise shipping system has the following pricing rules:
  • Free shipping when:
    • The order has 4+ items AND the total is $300+
    • Standard shipping is selected (4-5 business days)
  • Otherwise, shipping charges vary based on:
    • Number of items
    • Delivery speed (Next day, 2nd day, or Standard)
    • Order total (less than 300or300 or 300+)

Version 1: Using Aletyx Playground

Step 1: Access Aletyx Playground

  1. Navigate to playground.aletyx.ai or run locally:
  1. From the welcome screen, click New Decision to create an empty DMN Decision (even if we’re not using it, this will be a quick way to incorporate project dependencies consistent for decisions.
  2. Click Apply Accelerator
  3. Select the Decisions Accelerator
  4. Now you can either download the project that would be configured for decisions or use Aletyx Playground to synchronize with Git. If you do the synchronization, you will be able to either Open with VSCode directly from Aletyx Playground or clone it from the created repository link.

Step 2: Create and Edit the Decision Table

  1. Create a new spreadsheet with the name ShippingCharges.drl and save it as the type xls. The reason for using xls over xlsx is that the default settings for the Maven build will include the temporary file that Microsoft Office creates when a spreadsheet is actively opened.
  2. In the new spreadsheet start adding the following starting in cell A1:
  1. Review and modify the first RuleTable for orders under $300:
  1. Review and modify the second RuleTable for orders of $300 or more:

Step 4: Create Required Java Classes

Create two Java files in your project: Order.java
Charge.java

Step 5: Test Your Decision Table

  1. Click Deploy to create a dev deployment
  2. Once deployed, use the test interface to submit test orders:
    • Order 1: 2 items, 150total,1daydelivery(Expectedcharge:150 total, 1-day delivery (Expected charge: 35)
    • Order 2: 5 items, 400total,5daydelivery(Expectedcharge:400 total, 5-day delivery (Expected charge: 0 - free shipping)

Version 2: Java 17 Project with Maven

Step 1: Create a Maven Project

  1. Create a new Maven project with the following structure:
  1. Set up your pom.xml:

Step 2: Create the Model Classes

Create the Order and Charge classes in the ai.aletyx.model package as shown in the Playground version.

Step 3: Create the Decision Table

Create the Excel decision table as described above and save it to src/main/resources/rules/ShippingCharges.drl.xlsx.

Step 4: Create the Application Class

Create ShippingChargesApp.java:

Step 5: Build and Run the Application

  1. Build the project:
  1. Run the application:
  1. Follow the interactive prompts to test different orders:
    • Try an order with 2 items, $150 total, Next Day delivery
    • Try an order with 5 items, $350 total, Standard delivery

Benefits of Excel Decision Tables

  • Decision Analyst Friendly: Non-technical stakeholders can understand and modify rules
  • Centralized Rule Management: All business rules in one visible location
  • Easy Maintenance: Rules can be updated without code changes
  • Version Control: Excel files can be versioned alongside code
  • Rapid Iteration: Quick updates to business rules without recompilation