Skip to content
AI Agents

Merge Multi-Execution Dedup by Key with Count Reconciliation Report

10 nodes 5 0 Manual trigger
Download

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. 1.Manual Trigger starts two Code nodes emitting fictional branch A and B samples with overlapping keys and invalid keyless records
  2. 2.Merge in append mode with two inputs: each branch wired to its own input index
  3. 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. 4.It computes unique keys per input, their union, per-key occurrence counts, and compares output unique keys to the union (counts_match)
  5. 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. 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

  1. Import the JSON into n8n and open the workflow
  2. 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
  3. Verify ORD-1002 was kept from branch B (5 fields) and ORD-1001 from branch A (6 non-empty fields)
  4. Edge case: empty both sample arrays in the branch nodes and confirm status=no_input
  5. 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

Manual Trigger Code Merge If No Op Set

Details

Trigger Manual trigger
Nodes 10
Apps 6
Views 5
Downloads 0

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (10)

/

Read Me - Setup & Logic

Sticky Note

#1

Stage 2 - Dedup & Routing

Sticky Note

#2

Stage 3 - Final Report

Sticky Note

#3

Run Reconciliation Demo

Manual Trigger

#4

Branch A - Sample Orders

Code

#5

Branch B - Sample Orders

Code

#6

Append Raw Merge Output

Merge

#7

Dedup by Key and Reconcile Counts

Code

#8

Counts Match?

If

#9

Reconciled OK

No Op

#10

Alert Path - Count Deviation

No Op

#11

Build Final Reconciliation Report

Code

#12

Stamp Report Title

Set

#13
Stay in the loop

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

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime