How to insert only new records into Google Sheets (avoid duplicates) – beginner question

How to insert only new records into Google Sheets (avoid duplicates) – beginner question

Hi everyone,
I’m new to n8n and still building my first workflows, so sorry if this is a basic question :slightly_smiling_face:

I have a workflow that fetches quotations from an external API and saves them to Google Sheets.

Each quotation has a unique ID (processId).

What I want

  • Read the existing quotation IDs from the sheet

  • Insert only new quotations

  • Avoid duplicates every time the workflow runs

The issue

Even when I read the sheet first and try to compare IDs using an IF node, all items are still being inserted again.

My question

What is the recommended beginner-friendly way in n8n to:

  • Compare incoming items with existing rows in Google Sheets

  • Insert only the ones that don’t exist yet?

Is there a standard pattern or node combination for this?

Any guidance would really help. Thanks a lot! :folded_hands:

The IF node evaluates items one at a time and cannot compare against a dataset. Use a Merge node in “Compare Datasets” mode instead:

  1. Read existing rows with a Google Sheets node.
  2. Add a Merge node – Input 1 = sheet data, Input 2 = API data, match on processId, output “Items only in Input 2”.
  3. Append only those to the sheet.

Hi Diego! This is a really common challenge when starting out with n8n. I ran into the exact same issue when I was building my first workflows with Google Sheets.

What worked for me was using the Merge node set to “Remove Key Matches” mode. After your Google Sheets node that reads existing data, add a Merge node. Connect both your API data and the Sheets data to it, then configure it to compare using your processId field. This will output only the items from your API that don’t already exist in the sheet.

Another approach that some folks prefer is using the Code node to create a simple lookup set of existing IDs, then filter your incoming data against that set. Both work great, so pick whichever feels more intuitive for your workflow!

Hope this helps you get unstuck.