# Simple multiplication and other calculations

**URL:** <https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618>\
**Category:** Questions\
**Tags:** data-transformation\
**Created:** [September 18, 2023, 11:24am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618 "2023-09-18T11:24:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [September 18, 2023, 11:24am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/1 "2023-09-18T11:24:45Z")

</div>

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:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/3/031654e92ca1782753298564f22cb588c080781b.png)

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

---

<div class="post-metadata">

**Author:** ![EmeraldHerald](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/emeraldherald/32/35355_2.png) [@EmeraldHerald](https://community.n8n.io/u/EmeraldHerald)\
**Post date:** [September 19, 2023, 2:35pm UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/2 "2023-09-19T14:35:36Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/a/0a0c2ede76645f293586daff714e47944db91a0f.jpeg)

---

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [September 19, 2023, 10:09pm UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/3 "2023-09-19T22:09:17Z")

</div>

great!

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

---

<div class="post-metadata">

**Author:** ![EmeraldHerald](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/emeraldherald/32/35355_2.png) [@EmeraldHerald](https://community.n8n.io/u/EmeraldHerald)\
**Post date:** [September 20, 2023, 8:24am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/4 "2023-09-20T08:24:37Z")

</div>

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 🙇‍♂️

---

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [September 20, 2023, 5:52pm UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/5 "2023-09-20T17:52:58Z")

</div>

> [@EmeraldHerald](#):
>
> .toString().toFloat().toFixed(2).replace(‘.’,‘,’)

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

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/8/08d0ba77105462a159870831539c960b9b3c02bd.png)

---

<div class="post-metadata">

**Author:** ![EmeraldHerald](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/emeraldherald/32/35355_2.png) [@EmeraldHerald](https://community.n8n.io/u/EmeraldHerald)\
**Post date:** [September 21, 2023, 8:32am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/6 "2023-09-21T08:32:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [September 23, 2023, 6:17pm UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/7 "2023-09-23T18:17:08Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![EmeraldHerald](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/emeraldherald/32/35355_2.png) [@EmeraldHerald](https://community.n8n.io/u/EmeraldHerald)\
**Post date:** [September 26, 2023, 8:43am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/8 "2023-09-26T08:43:46Z")

</div>

Hi @fxholl 👋 Sorry for the delay, as I was out yesterday 🙇‍♂️

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 😅

---

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [October 5, 2023, 2:42pm UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/9 "2023-10-05T14:42:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![batistaamorem](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/batistaamorem/32/15975_2.png) [@batistaamorem](https://community.n8n.io/u/batistaamorem)\
**Post date:** [November 5, 2023, 12:10am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/10 "2023-11-05T00:10:15Z")

</div>

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

[![](https://img.youtube.com/vi/EwN-aJE7bAA/maxresdefault.jpg "Criando Calculos Matematicos com o N8N") ](https://www.youtube.com/watch?v=EwN-aJE7bAA)

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 6, 2023, 10:11am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/11 "2023-11-06T10:11:41Z")

</div>

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 👍

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

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 6, 2023, 10:11am UTC](https://community.n8n.io/t/simple-multiplication-and-other-calculations/30618/12 "2023-11-06T10:11:48Z")

</div>

Closed on November 6, 2023, 10:11am UTC


