Simple multiplication and other calculations

I am getting a variable “total_point_balance” and i would like to multiply it by an integer:

{{ $(‘Split In Batches’).item.json[“total_point_balance”] x “5” }}

I tried the above but i am getting invalid syntax:

Are simple calculations possible in n8n?

Information on your n8n setup

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

Hi @fxholl :wave: Sure is possible - all you’d need to do is replace the x in your equation with *. Like so:


I have a follow-up question about formating the resulting number.

In your example, {{ $json.number * 6 }} is 30 . I need the number to be “30,00”. I normally append .toFloat().toFixed(2).replace(“.”,“,”), but I am unsure where to append this

No problem, @fxholl - you could do this like this: {{ $json.number.toString().toFloat().toFixed(2).replace('.',',') }}. If you try to simply use .toFloat(), it’s only callable on a String :bowing_man:

Here is the complete example:

{{ $(‘Split In Batches’).item.json[“total_currency_balance”] *5 }} returns “75”.

But I need “75,00”

I tried {{ $(‘Split In Batches’).item.json[“total_currency_balance”]…toString().toFloat().toFixed(2).replace(‘.’,‘,’) *5 }} but it returns null

Ah, that would be because you’d need to do the calculation before you convert the integer over to a string :sweat_smile: You can then use the rest of the methods I mentioned after multiplying to give you “75,00”, if that makes sense?

Yes, it makes sense. I guess my next question is whether there is a way to do that in the same node, ou or whether I need one node to get the min(a,b) and then another node to change the period to a comma.

I tried within the same node with no luck. If I have to use 2 nodes, I can figure out which ones (probably a Set node and then the HTTP node).

1 Like

Hi @fxholl :wave: Sorry for the delay, as I was out yesterday :bowing_man:

Could you give an example of what you tried in the same node?

One benefit to using multiple nodes here would be that the longer your chain of methods, the harder it might be to follow what you’re doing in future if you revisit this workflow after some time :sweat_smile:

I opted to use two nodes and it working fine, thank you for your help.

1 Like

Segue o video ensinando a fazer calculos no N8N de forma simples e prática:

Hey @batistaamorem,

You have posted this link on 6 posts now, While we want to encourage community content maybe one post would be better if you are trying to share something you have created so we can easily share it as well :+1:

I have deleted some of the other posts and closed those other topics as they were old as well.