Logic Composer
Decision table
Map combinations of conditions to outcomes in rows, where the first matching row decides the result.
A decision table lays a business decision out as a grid. Each decision is a column the table checks, such as customer segment or quote amount. Each output is a column the table returns, such as discount percent. Each row is one rule: when all its conditions hold, the table returns that row’s outputs. Because business users can read it like a spreadsheet, a decision table is the best home for pricing, routing and eligibility rules that change often.
Parts of a decision table
Section titled “Parts of a decision table”| Part | Where you define it | What it is |
|---|---|---|
| Decisions | Decisions tab | The values each row checks. Each has a Name, a Type and an Expression that works out the value, usually from an input or data, for example Account.customertypecode. |
| Outputs | Output tab | The values the table returns, each with a name and a type. An output can be a list. |
| Rows | Decision Table tab | Numbered rules. Each row has a condition for each decision (under WHEN) and a value for each output (under THEN). |
Build a decision table
Section titled “Build a decision table”- Create a logic block and choose the Decision table card. See Create a logic block.
- Add the inputs on the Input tab, and rows or queries on the Data tab.
- Add a decision for each value a row checks: give it a Name, a Type and an Expression.
- Add an outcome for each value the table returns.
- Fill in the rows on the Decision Table tab: for each row, set a condition in each decision cell and a value in each output cell.
- Make the last row a catch-all by leaving all its condition cells empty.
- Save, then select Run to test each row.
Work with the table
Section titled “Work with the table”- The toolbar shows a summary such as “11 rows · 3 decisions · 2 outputs”.
- WHEN and THEN bands sit over the decision and output columns. Each column shows its type under its name.
- Each column has an options menu: Insert Decision, Insert Output, Move Left, Move Right, Delete Column.
- Each row has an options menu: Insert row above, Insert row below, Move Up, Move Down, Delete Row. You can also drag a row by its number to reorder it (“Drag to reorder”).
- Use the add-row bar under the table to add a row at the end.
- Cells with problems are marked so you can find them in a large table. The table scrolls inside its own area, and Expand gives it the whole window.
Deleting a decision or an output removes it from every row of the table. The editor asks you to confirm first.
Set a condition quickly
Section titled “Set a condition quickly”Select a condition cell to open a small popover titled with the decision, for example Customer segment is…
- Pick a Comparison. Only the comparisons that suit the column’s type are listed.
- Type or choose a Value. For Yes/No and Choice columns, pick from a list. The value is checked against the type (“Enter a valid Currency”).
- Select Apply.
The comparisons the popover can offer are:
- is equal to, is not equal to
- is less than, is less than or equal to, is greater than, is greater than or equal to
- contains, does not contain, starts with, does not start with, ends with, does not end with
- is Yes, is No
- is empty, is not empty
- includes, does not include (for lists)
Use the arrow keys to move between comparisons. When you need more than one comparison, such as a range, or a condition that uses other inputs, functions, dates or lookups, select Open full editor to switch to the full expression editor. Conditions that involve inputs, functions, dates or lookups open in the full editor directly. In the table, conditions read briefly, such as = Gold, ≥ 10000 or is not empty.
How it behaves
Section titled “How it behaves”- Top to bottom, first match wins. Rows are checked in order. The first row whose conditions all hold provides the outputs, and no later row is checked. Put specific rows before general ones.
- An empty condition cell matches anything. Use it for “any value”.
- No match is an error. If no row matches, the run fails with “Decision table evaluation failed to reach a decision.” Add a last row with all condition cells empty as a catch-all.
- Decision values are worked out from their expressions, so a decision can be a calculation, for example the number of days since the customer’s last order, not only an input.
- Comparisons follow the expression rules. An empty number counts as 0, so
≥ 10000does not match an empty amount, but= 0does. Text is equal to is case-sensitive; contains, starts with and ends with ignore case. See Operators.
Example: quote discount
Section titled “Example: quote discount”Inputs: CustomerSegment (Choice), QuoteAmount (Currency), IsFirstOrder (Yes/No)
Decisions: Segment = CustomerSegment, Amount = QuoteAmount, First order = IsFirstOrder
Outputs: DiscountPercent (Decimal Number), DiscountReason (Text)
| # | Segment | Amount | First order | DiscountPercent | DiscountReason |
|---|---|---|---|---|---|
| 1 | = Gold | ≥ 10000 | 20 | Gold customer, large order |
|
| 2 | = Gold | 12 | Gold customer |
||
| 3 | = Silver | ≥ 5000 | 10 | Silver customer, medium order |
|
| 4 | = Silver | 8 | Silver customer |
||
| 5 | is Yes | 10 | First order |
||
| 6 | ≥ 10000 | 5 | Large order |
||
| 7 | 0 | No discount |
For a Silver customer with a quote of 7,500 that is not their first order, rows 1 and 2 fail on segment, row 3 matches, and the table returns 10 and Silver customer, medium order. Row 7 guarantees that every quote gets an answer.
If row 2 came before row 1, Gold customers would never reach the 20% rule: order matters.
Related
Section titled “Related”- Decision tree: when different cases ask different questions
- Inputs and outputs
- Operators
- Run and test