Merge Multi-Execution Dedup by Key with Count Reconciliation Report
Read the execution path horizontally, with supporting AI nodes below. Layout changes affect this preview only; the download stays unchanged.
Loading workflow…
Workflow Description
A self-contained n8n template that fixes duplicate records caused by merge node multi-execution. Two same-schema branch samples enter an append-mode Merge (one input per branch), then a runOnceForAllItems Code node validates the key type, deduplicates by record_key keeping the most field-complete variant, and reconciles input/output counts. An If node routes matched counts to the OK path and deviations to an internal alert path, ending in one consolidated report listing duplicated keys with occurrence counts. No external calls.
How it works
- 1.Manual Trigger starts two Code nodes emitting fictional branch A and B samples with overlapping keys and invalid keyless records
- 2.Merge in append mode with two inputs: each branch wired to its own input index
- 3.A runOnceForAllItems Code node validates key type (string/number), trims it, counts invalid keyless records, and dedups keeping the variant with the most non-empty fields
- 4.It computes unique keys per input, their union, per-key occurrence counts, and compares output unique keys to the union (counts_match)
- 5.If routes match to the OK NoOp and deviation to the alert NoOp; both meet in a final Code node producing exactly one report item
- 6.A final Set stamps the report title with includeOtherFields preserving all fields
Use cases
- Removing duplicate records after merging two simultaneously active branches in n8n
- Locally verifying merge input counts match output counts
- Diagnosing partial merge results that emit rows from only one input
- Producing a reconciliation report before handing data to any downstream system
Requirements
- n8n 2.44.6 with Code, Set, If, Merge, NoOp and StickyNote nodes
- Two same-schema JSON inputs containing record_key and __source to identify the branch (replace the two sample emitters with your real sources)
- No credentials and no external calls required
Setup and testing in n8n
- Import the JSON into n8n and open the workflow
- Execute the Manual Trigger and inspect Stamp Report Title output: 9 items received, 4 unique, counts_match true, ORD-1001 (3x) and ORD-1002 (2x) duplicated, 2 invalid records
- Verify ORD-1002 was kept from branch B (5 fields) and ORD-1001 from branch A (6 non-empty fields)
- Edge case: empty both sample arrays in the branch nodes and confirm status=no_input
- To test the deviation path, manually paste the dedup output twice into the Merge inputs and watch If route to the alert path
Service Value
Ready-made workflow template for automation delivery and service execution.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (10)
Read Me - Setup & Logic
Sticky Note
Stage 2 - Dedup & Routing
Sticky Note
Stage 3 - Final Report
Sticky Note
Run Reconciliation Demo
Manual Trigger
Branch A - Sample Orders
Code
Branch B - Sample Orders
Code
Append Raw Merge Output
Merge
Dedup by Key and Reconcile Counts
Code
Counts Match?
If
Reconciled OK
No Op
Alert Path - Count Deviation
No Op
Build Final Reconciliation Report
Code
Stamp Report Title
Set
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides