DMN Decision Table Hit Policies Explained – With Clear Examples
In DMN, Hit Policies define how the decision table evaluates rules and returns results.
Misunderstanding hit policies is one of the most common causes of wrong decision outcomes in production.
This blog explains:
What DMN Hit Policies are
All major hit policies (FIRST, UNIQUE, ANY, COLLECT, PRIORITY)
Real-world examples
Best practices (with Camunda DMN usage in mind)
1️⃣ What Is a DMN Hit Policy?
A Hit Policy defines:
How many rules can match
Which result is returned if multiple rules match
Without the correct hit policy:
Decisions may return unexpected values
Rules may conflict silently
Production logic may break
2️⃣ FIRST – First Matching Rule Wins
🔹 Behavior
Rules are evaluated top to bottom
The first matching rule is returned
Other matching rules are ignored
🧩 Example: Discount Calculation
| Customer Type | Discount |
|---|---|
| Premium | 20% |
| Regular | 10% |
If customer = Premium → 20%
✅ Use when:
Rules are ordered by priority
Only one result should be returned
❌ Risk:
Wrong rule order = wrong decision
3️⃣ UNIQUE – Exactly One Rule Must Match
🔹 Behavior
Only one rule is allowed to match
If multiple rules match → error
If no rule matches → no result
🧩 Example: Tax Slab
| Income Range | Tax |
|---|---|
| 0–50k | 5% |
| 50k–100k | 10% |
Only one slab can apply.
✅ Use when:
Rules are mutually exclusive
Data quality is high
❌ Risk:
Overlapping rules cause runtime errors
4️⃣ ANY – Multiple Matches Allowed, Same Result Required
🔹 Behavior
Multiple rules may match
All matched rules must return the same result
Otherwise → error
🧩 Example: Eligibility Check
| Condition | Eligible |
|---|---|
| Age > 18 | Yes |
| Country = EU | Yes |
Multiple rules match → result is Yes
✅ Use when:
Multiple conditions lead to the same outcome
5️⃣ COLLECT – Combine Results
🔹 Behavior
All matching rules are collected
Can be combined using:
COLLECTCOLLECT +COLLECT <COLLECT >COLLECT #
🧩 Example: Risk Scoring (COLLECT +)
| Risk Factor | Score |
|---|---|
| High Debt | 40 |
| Missed Payments | 30 |
Result = 70
✅ Use when:
You need aggregated results (sum, min, max, count)
6️⃣ PRIORITY – Highest Priority Result Wins
🔹 Behavior
Multiple rules may match
Result with highest priority is returned
Priority defined by output value ordering
🧩 Example: Approval Level
| Condition | Level |
|---|---|
| Amount > 100k | HIGH |
| Amount > 50k | MEDIUM |
Result = HIGH
✅ Use when:
Business defines clear output priorities
7️⃣ Comparison Table (Quick Reference)
| Hit Policy | Multiple Matches | Result Rule |
|---|---|---|
| FIRST | Allowed | First match |
| UNIQUE | ❌ | Exactly one |
| ANY | Allowed | Same result |
| COLLECT | Allowed | Aggregated |
| PRIORITY | Allowed | Highest priority |
8️⃣ Common Mistakes in Production
❌ Using FIRST without rule ordering
❌ Using UNIQUE with overlapping ranges
❌ Using ANY with different outputs
❌ Forgetting aggregation type in COLLECT
❌ Assuming PRIORITY without defining output order
9️⃣ Best Practices (Camunda DMN)
✅ Always document the chosen hit policy
✅ Test overlapping rules
✅ Prefer UNIQUE for clean business rules
✅ Use COLLECT for scoring models
✅ Validate decisions with real data
✅ Review DMN tables before production release
🔟 Interview Question (Bonus)
Q: Which hit policy should be used for scoring systems?
A: COLLECT (usually COLLECT +)
Q: Which hit policy throws an error on multiple matches?
A: UNIQUE
💼 Professional Support Available
If you face issues with DMN decision tables, wrong decision outcomes, or production decision errors, I provide paid consulting, DMN reviews, production debugging, and focused trainings.
📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 Website: IT Trainings | Digital lectern | Digital rostrum | Digital metal podium
Comments
Post a Comment