This is the tested version I offered in the Tips topic. Set to run every morning at 07:00, it reads yesterday’s orders at a source and a destination, matches them on order_id, and sends one email listing missing, extra and mismatched rows. It sends on clean days too.
I wrote “orders and invoices” there; this version compares orders only.
What arrives (mixed test day):
Subject: Count check 2026-10-22: 2 missing, 2 extra, 2 different
Daily count check for 2026-10-22.
Source: 10 orders. Destination: 10 rows (read up to 02:00 today).
Missing at the destination (2): 2004, 2007
Only at the destination (2): 2005 (second copy), 2999 (not in the source)
Different (2):
- 2003: amount 245 -> 254
- 2006: status refunded -> paid
This message is sent every day, also when everything matches. If it does not arrive, the check itself has stopped.
Why Always Output Data is on
Without it the check itself can go quiet. Two control copies:
- Off on Compare Datasets, clean day: the execution succeeded, the Code node never ran, no email.
- Off on the two reads, empty day: the execution succeeded, no email.
How it decides
- Source: orders created yesterday. Destination: rows written from yesterday 00:00 to 02:00 today, minus rows for other days’ orders. So order 2010 (written 00:03) counts as present and order 2007 (written 02:30) as missing.
- Compare Datasets uses “Include Both Versions” and skips
id, createdAt, updatedAt, written_at. - The Code node reads outputs 0, 2 and 3 (In A only, Different, In B only) by index and skips the empty item Always Output Data adds when nothing is missing.
Extra rows and mismatched fields came up in replies from @runlookout and @Mahdi_Eqbal.
Setup
- Create two Data Tables. The workflow finds them by name:
count_check_source:order_id(string),order_created_at(date),amount(number),status(string)count_check_destination: the same, pluswritten_at(date)
- Paste the JSON below into an empty workflow.
- In “Send the daily message”, pick your SMTP credential and set the two
example.testaddresses. - The JSON sets no time zone, so 07:00 and “yesterday” follow your instance default (tested with Europe/Istanbul). The 2-hour margin is
destination_toin “Set the window” (the “02:00” in the message text is set in the Code node). - Publish.
For your own systems, swap the two Read nodes (I have only run it on Data Tables). Keep Always Output Data on, keep order_id and order_created_at, and add the columns your destination fills in by itself to “Fields to Skip Comparing”.
Tests
12/12 checks passed on n8n 2.43.6 (self-hosted, Docker, synthetic data, local Mailpit), on my instance and on a fresh one after pasting this JSON. The Schedule Trigger started every run itself (one-off cron a few seconds ahead). I also moved the daily rule a few minutes ahead once: it fired at the set minute and the email arrived.
Scenarios: mixed day, clean day, only an extra row, both sides empty, destination empty, and the two controls.