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?