Problems appending google sheets

Hey - I am trying create a a simple (I think, I am new to this) workflow that populates 3 master worksheets each time a .csv is dropped into a google drive.

I have been through the ringer with chatGPT (I have no idea what I am doing) going back and forth trying to get this working but to no avail.

Each day a .csv is dropped into a google drive, this will then populate a mastersheet in the google drive and it works - the problem is that when the second file goes into the drive it either overides the mastersheets records or balloons the numbers.

The .csv contains information from Orum on calling stats (clients) and I have had the code nodes group the Clients together. I want it to behave as such:

File 1
Client A has 1200 Dials

File 2
Client A has 1000 Dials

Mastersheet shows Client A has 2200 dials to date.

Happy to provide any other information, attached workflow. Thanks

Share the output returned by the last node

  • **Running n8n via n8n cloud
  • **Operating system: Sequioa 15.5 (24F74)
  1. Trigger – Google Drive Trigger → “New File in Folder” (your CSV folder).
  2. Download – Google Drive node → Download the file (use the File ID from trigger).
  3. Parse CSV – Spreadsheet File node → Operation: “Read Binary File” → choose the downloaded file → Return JSON.
  4. Group & Sum – Function node with code:
const data = items.map(i=>i.json);
const sums = {};
for (const {Client,Dials} of data) {
  sums[Client] = (sums[Client]||0) + Number(Dials);
}
return Object.entries(sums).map(([Client,Dials])=>({json:{Client,Dials}}));
  1. Split – SplitInItems so each Client/Dials is its own item.
  2. Lookup – Google Sheets node → Operation: “Lookup” → Sheet: your master → Column: “Client” → Value: {{$json.Client}}.
  3. Route – IF node → Condition: {{$node["Lookup"].json["Client"] !== undefined}}
  • True (exists):
    1. Function or Set node → calculate NewDials = $node["Lookup"].json.Dials + $json.Dials.
    2. Google Sheets node → Operation: “Update Row” → Row: {{$node["Lookup"].json.__row}} → set “Dials” = {{$json.NewDials}}.
  • False (new client):
    • Google Sheets node → Operation: “Append” → add row { Client: {{$json.Client}}, Dials: {{$json.Dials}} }.
  1. (Optional) – Google Drive node → Move File to a “processed” folder so it won’t run again.

That way, every incoming CSV is parsed, summed per client, and your master sheet is updated (new rows or cumulative totals) automatically.

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