# Decision tables (/docs/guides/decision-tables)



A decision table is a matrix: **rows are rules**, **columns are conditions and results**, and a
blank condition cell means "any". Tables are reused by decisions, so one table can back many
flows.

## Hit policies [#hit-policies]

When several rules match, the hit policy decides what happens:

| Policy       | Behaviour                                                        |
| ------------ | ---------------------------------------------------------------- |
| **FIRST**    | Stops at the first matching rule (top to bottom).                |
| **PRIORITY** | Respects the priority column.                                    |
| **ALL**      | Collects every matching rule (list outputs collect every match). |
| **COLLECT**  | Gathers everything as a list.                                    |

A rule with **no conditions at all** is the table's *otherwise* row and is allowed only as the
**last** rule — anywhere else it would make the rows below it unreachable, and the validator says
so.

## Coverage analysis [#coverage-analysis]

Tables are analysed for coverage, shown live in the editor and returned as warnings on validate
and publish:

* inputs no rule covers,
* rules that overlap with different results,
* rules that can never answer because earlier rules match everything they would.

Each input column is split into the regions its cells can tell apart, and every combination is
checked. Cells the analysis cannot reason about (`expression`, `matches`, `contains`) count as
"maybe", which keeps every finding a real one rather than a guess.

## Spreadsheets [#spreadsheets]

The table editor exports the rules to Excel (`.xlsx`) or CSV and imports them back. One row per
rule, columns `description`, `enabled`, `priority`, `in:<key>` and `out:<key>`, and cells written
the way the console shows them:

```
> 1000       1000..5000        in [DO, RU]        != US        matches ^A        expr: amount * 2
```

An import **replaces the rules** (hit policy and defaults stay), keeps the types of known columns,
adds unknown ones typed from their values, and names the row and column of anything it cannot read.
