Check if a value already exists in a specific Google Sheets column before adding a new row

Hi everyone,

I’m building a workflow where I get a list of items from one source and then add them into a Google Sheet.
Before inserting a new row, I want to check if a given value (X) already exists in a specific column (e.g., column A with header Title) of the sheet. If it exists → skip; if not → insert.


What I have

  • Get row(s) in sheet → fetches the target sheet (about ~140 rows, row 1 = headers).

  • The incoming item from the previous node contains a property title (string).


What I tried

  1. IF Node with “String → contains”

    • Left: {{$json.title}}

    • Right: {{$json.Title}} (from the sheet)
      → This only checks against the current $json row, not all rows from the sheet.

  2. Expression with array search
    Tried to check across all rows:

    {{ $items("Get row(s) in sheet") .map(i => (i.json.Title || '').toString().trim().toLowerCase()) .includes(($json.title || '').toString().trim().toLowerCase()) }}

    This sometimes threw errors (when empty cells exist) or always returned the same result, depending on where it’s placed.

  3. Using .some()

    {{ $items("Get row(s) in sheet") .some(i => String(i.json.Title || '').trim().toLowerCase() === String($json.title || '').trim().toLowerCase() ) }}

    Not sure which IF operator is correct here to handle this boolean properly.


What I want

A simple, reliable way to say:

“For each incoming item, check if any row in the Google Sheet already has the same value in a specific column (case-insensitive, ignoring extra spaces). If yes → skip; if no → insert.”


My questions

  • Is using .some() in an IF expression supported? If so, how do I connect it so the IF node gets a true/false result?

  • Is it better to calculate this once in a Set or Code node (add a exists boolean) and then branch with IF?

  • Is there a built-in Google Sheets “find” or “search” method in n8n that avoids fetching all rows each run?

  • Any best practices for normalizing values before comparing (e.g., case, spaces, punctuation)?

Thanks in advance — I’m looking for the cleanest pattern for this since it feels like a common use case.

Hey @Luca2 hope all is good.

I would suggest pulling rows first, processing them to see if you can find what you are looking for, and if nothing is found - make an insert.

Yes that is what I did but how can I check if it contains XYZ?

It should check for example all rows in column A → if it exists, continue and if not then stop.

For example I want to check if the Webinar ID is already in my google sheet. But when I use the if node for it then it only checks one row and not all of them.

Ah I see, in this case I would try something like this:

or this

Thank you.

I was thinking about the following solution:
if I use the filter in google sheet straight away: For example: column s needs to be the same Webinar ID as {{ $json.topic }}

Is this the same?

sure you can totally go an extra step and first try to get the row like this

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.