# Simple math without js

**URL:** <https://community.n8n.io/t/simple-math-without-js/6598>\
**Category:** Questions\
**Tags:** data-transformation\
**Created:** [July 4, 2021, 9:05am UTC](https://community.n8n.io/t/simple-math-without-js/6598 "2021-07-04T09:05:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjan\_den\_Ouden](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/arjan_den_ouden/32/2279_2.png) [@Arjan\_den\_Ouden](https://community.n8n.io/u/Arjan_den_Ouden)\
**Post date:** [July 4, 2021, 9:05am UTC](https://community.n8n.io/t/simple-math-without-js/6598/1 "2021-07-04T09:05:16Z")

</div>

Looking at:

> **[Assign values to variables using the Set node | n8n workflow template](https://n8n.io/workflows/526-assign-values-to-variables-using-the-set-node/)**
>
> workflow-screenshot

How could i multiply the number 20 by 2?  
Simply 20 \* 2 doesn’t work returns the string (i guess) 20 \* 2.  
There’s an earlier demand for a calculation node but i can’t find it (yet?):

> <https://github.com/n8n-io/n8n/issues/18>
>
> hey @janober ,
> 
> does it make sense a calculation node?
> something that would i…nteract with data to transform it
> 
> i think would be something number\_transform (with math operations)
> string\_transform (for string operations)
> 
> does it make sense?

In reality i’m facing the following issue; i receive a quantity and price from a source, but need to calculate line total to be able to hand it over to the target.

Probably easy in Function Item, but i don’t know how to refer to results in earlier nodes there and would like to prevent to need to learn javascript (that’s why i use n8n 🙂 )

Thank you in advance for any helpful tips 🙂

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [July 4, 2021, 4:20pm UTC](https://community.n8n.io/t/simple-math-without-js/6598/2 "2021-07-04T16:20:28Z")

</div>

Welcome to the community @Arjan_den_Ouden

If you provide an example of the input and the desired output, I can help you with the function node.

---

<div class="post-metadata">

**Author:** ![Arjan\_den\_Ouden](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/arjan_den_ouden/32/2279_2.png) [@Arjan\_den\_Ouden](https://community.n8n.io/u/Arjan_den_Ouden)\
**Post date:** [July 4, 2021, 4:39pm UTC](https://community.n8n.io/t/simple-math-without-js/6598/3 "2021-07-04T16:39:14Z")

</div>

Hi Ricardo,  
Tnx for your reply, the input is the example in this n8n website:  
[https://n8n.io/workflows/526](https://n8n.io/workflows/526)  
i would like to change the output of 20 to be multiplied by, let’s say 2, so 40 is the desired outcome.  
When i do 20 \* 2 in the formula editor this is parsed as a string as the outcome then is 20 \* 2 and not 40. So is would like to perform basis math somewhere.

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [July 4, 2021, 4:44pm UTC](https://community.n8n.io/t/simple-math-without-js/6598/4 "2021-07-04T16:44:12Z")

</div>

The example below should do it.

```
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -1910,
        40
      ]
    },
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "number",
              "value": 20
            }
          ],
          "string": [
            {
              "name": "string",
              "value": "From n8n with love"
            }
          ],
          "boolean": [
            {
              "name": "boolean",
              "value": true
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "position": [
        -1620,
        40
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "number",
              "value": "={{$node[\"Set\"].json[\"number\"] * 2}}"
            }
          ],
          "string": [
            {
              "name": "string",
              "value": "From n8n with love"
            }
          ],
          "boolean": [
            {
              "name": "boolean",
              "value": true
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "position": [
        -1380,
        40
      ],
      "typeVersion": 1
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Arjan\_den\_Ouden](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/arjan_den_ouden/32/2279_2.png) [@Arjan\_den\_Ouden](https://community.n8n.io/u/Arjan_den_Ouden)\
**Post date:** [July 4, 2021, 4:47pm UTC](https://community.n8n.io/t/simple-math-without-js/6598/5 "2021-07-04T16:47:59Z")

</div>

> [@RicardoE105](#):
>

Ah ok, i see now, thank you so much!

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [July 4, 2021, 5:01pm UTC](https://community.n8n.io/t/simple-math-without-js/6598/6 "2021-07-04T17:01:30Z")

</div>

Of course. Let us know if you have more questions.

---

<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:12am UTC](https://community.n8n.io/t/simple-math-without-js/6598/8 "2023-11-06T10:12:54Z")

</div>


