GSheet get rows with multiple input → results only partial, and repeated

Describe the problem/error/question

I’m struggling with understanding why and how the output of a node that runs multiple times is repeated instead of concatenates/merged.

In this simple workflow, a Google Spreadsheets node is used on one spreadsheet document to get the rows of its two sheets by their name. The node gets these two sheets’ names from the previous code node which inputs the array of two items into the Spreadsheet node.

The Spreadsheet node seems to run two times (supposedly for each of the sheetName items, where can i confirm this?). But its final output just repeats the rows from only the first sheets two times, instead of containing the rows of both sheets.

If there would be just one set of three rows with the data from one sheets in the final output, then i’d guess the node runs only once, or, after multiple runs, only the first or last result might be used. But the data from only the first sheet is repeated n times (n is the number of items the spreadsheet node gets a s input – and btw, if i add a third sheet, the data from the first sheet gets repeated three times).

What’s going on and what concept am i not getting here?
Is the sheet node really running once for each input item?

Please share your workflow

Data in the Google Spreadsheet:

Sheet “ONE”:

ID
ONE A1
ONE A2
ONE A3

Sheet “TWO”:

ID
TWO A1
TWO A2

Original: n8n-test-sheets - Google Sheets

Share the output returned by the last node

Expected output:

[
  {
    "row_number": 2,
    "ID": "ONE A1"
  },
  {
    "row_number": 3,
    "ID": "ONE A2"
  },
  {
    "row_number": 4,
    "ID": "ONE A3"
  },
  {
    "row_number": 2,
    "ID": "TWO A1"
  },
  {
    "row_number": 3,
    "ID": "TWO A2"
  }
]

Actual output:

[
  {
    "row_number": 2,
    "ID": "ONE A1"
  },
  {
    "row_number": 3,
    "ID": "ONE A2"
  },
  {
    "row_number": 4,
    "ID": "ONE A3"
  },
  {
    "row_number": 2,
    "ID": "ONE A1"
  },
  {
    "row_number": 3,
    "ID": "ONE A2"
  },
  {
    "row_number": 4,
    "ID": "ONE A3"
  }
]

Information on your n8n setup

  • n8n version: 1.74.3
  • Database (default: SQLite): n8n cloud
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: n8n cloud

Ok, by now i understood what’s happening, here’s the rundown for anyone running into the same kind of problems:

  • The workflow graph does not model the flow of control but the flow and “morphing” of data.
  • The previous node’s output is the (only) input for the following node.
  • If i have to re-use/reference output from a node further “ago”, then i’d have to explicitly reference that data.
  • A node runs for every input item (by default) and assembles its output items each time. In my case that means the GSpreadsheet node is executed multiple times (since the previous node inputs multiple items). But since it just reads the same rows from the same sheet over and over again, those get repeated in the final item list output of the GSpreadshet node, while that specific node doesn’t forward any input data into its output.
1 Like

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