Dynamic expressions wont work in Google sheet node

Describe the problem/error/question

Hello! Im doing some tests regarding the google sheet node and noticed that the node wont work if the expression output is dynamic. It just looks for the first thing that matches and dump all the data in there.

What is the error message (if any)?

None

Please share your workflow

Share the output returned by the last node

[...
{
"type": "financial",
"title": "title",
"link": "link"
},
...]

“financial” here is the output of $json.type coming from the code node
and it just dumps all the data in the first sheet it matches eventhough the output $json.type is dynamic as seen in the dump text in the sheet. The other sheets are empty.

Information on your n8n setup

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

I made a simple project

Trigger outputs an object with the sheet name and content

[
  {
    "sheet": "Sheet1",
    "title": "this is a text"
  },
  {
    "sheet": "Sheet2",
    "title": "Hello"
  }
]

Desired output:
Sheet2 contents should be dump in the sheet named Sheet2

Actual output
All dump into sheet 1

Hi! First of all, you have to change your Google Sheets node options.
Start with “Mapping column mode” — change it to “Map each column below”, then click “Add field.”
You’ll see your column names from the sheet appear after clicking “Add field.” Then, choose your column name and enter your value. You can also drag your values from the previous node.

2- If you don’t use a “Split Out” node, your Google Sheets node will only append the first item to your sheet.
Add a “Split Out” node between your Code node and Google Sheets node so you can append multiple rows to your sheet.

I don’t know if I did it correctly just as you said but I updated the simple test

Is this the config that you are talking about?

Your main goal is to add rows according to the sheets name, right? Use “Switch” Node. Like an example in below. In this situation, you won’t have to make the sheet name dynamic.
Switch Node example: Financial > output 0 > Your sheets node sheet name: financial

I can’t use the dynamic value for the sheet name?

Its just too repetitive, 4 nodes doing the same thing.

I think it can be used, but I couldn’t fully understand why it didn’t work. Maybe it’s related to the Google Sheets API. It might be necessary to specify which sheet to write to before execution, rather than dynamically. Sorry that i couldn’t help.

1 Like