Preform mathematical operations on variables

Hello guys.
I’ve created a workflow with N8N that reads data from a Google sheet and performs some actions afterwards. I want to perform some mathematical actions on dome fields of Google sheet like adding numbers to them. I tried {{ $json.Rep }}+{{ 1 }} but it shows 2+1.
How can I do this?
I am using the latest version of N8N on my own server via docker.
Is there any documentation for this?

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Keep in mind that javascript can only be placed inside of {{ }}. Everything outside will just be text, so the + is just being treated like text here instead of an operator. You can put almost anything inside of the {{ }} that you could do on one line of JS.

Instead you want to do this {{ $json.Rep + 1 }}.
You could even use another variable like this {{ $json.Rep + $json.amountToAdd }}

You might end up getting unexpected results here though. If you get a result of “21” instead of “3”, then use this expression instead {{ Number($json.Rep) + 1 }}


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