Can't change the sheet of google sheets dynamically

Describe the problem/error/question

Hello!

I’m working on an automation that receives scheduling data and processes it using an agent. The agent returns only the month, which I want to use in a Google Sheet, where each sheet corresponds to a specific month.

I want to use the Sheets node and set the sheet selection to “By Name” instead of “By List”, using {{$json.month}}—returned by my agent—as an expression.

What is the error message (if any)?

It can’t find the sheet, and the information that comes in {{$json.month }} is correct!

Please share your workflow

Share the output returned by the last node


WhatsApp Image 2025-03-05 at 16.43.55

Sheet with name Abril not found

Information on your n8n setup

  • **n8n version:1.81.4
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: ubuntu 20.04

Just a wild guess. If output contains any whitespaces (e.g. newline character) then $json.output.trim() might help.

2 Likes

Thank you very much Sir!!
U are my savior
“I’ve been banging my head on the keyboard for 30 hours.” :dizzy_face:‍:computer:

1 Like

@Wil_Scarpelli I am happy this actually helped. It was a blind shot.

If you do not mind, please like my post above and mark it as a solution.
The latter will help others to find the solution if they stumble across similar issue.

a headshot u mean :slight_smile:

1 Like

It happened to be, but I did not really see the target when I was giving it a shot :sweat_smile:

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