# Formula in expression (mathematics)

**URL:** <https://discourse.nodered.org/t/formula-in-expression-mathematics/46216>\
**Category:** General\
**Created:** [25 May 2021 12:44 UTC](https://discourse.nodered.org/t/formula-in-expression-mathematics/46216 "2021-05-25T12:44:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [25 May 2021 12:44 UTC](https://discourse.nodered.org/t/formula-in-expression-mathematics/46216/1 "2021-05-25T12:44:06Z")

</div>

In a change node (see flow) I need to use the formula below:

_value = 10 ^ ((x-109) / 32)_

but I have no idea what is the correct way to put this formula in there. Of course I have tried different ways but without success. Could someone help me?

 ![Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a9784eb311faf3bf6cdf45f7fa38cef1c25c446.png)

```auto
[{"id":"c559743c.82b088","type":"tab","label":"Formula","disabled":false,"info":""},{"id":"197314e1.24d27b","type":"debug","z":"c559743c.82b088","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":160,"wires":[]},{"id":"75cea3ad.e7730c","type":"inject","z":"c559743c.82b088","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"80","payloadType":"num","x":130,"y":100,"wires":[["e4aa1f6.b0285e"]]},{"id":"e4aa1f6.b0285e","type":"change","z":"c559743c.82b088","name":"Change to Value","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t\"Value\": payload * 1\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":160,"wires":[["197314e1.24d27b"]]},{"id":"ae6e09de.575678","type":"inject","z":"c559743c.82b088","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"230","payloadType":"num","x":130,"y":220,"wires":[["e4aa1f6.b0285e"]]},{"id":"f2e12f3e.f44ab","type":"inject","z":"c559743c.82b088","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":130,"y":160,"wires":[["e4aa1f6.b0285e"]]}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 May 2021 12:48 UTC](https://discourse.nodered.org/t/formula-in-expression-mathematics/46216/2 "2021-05-25T12:48:12Z")

</div>

The JSONata expression for that equation is:

```auto
$power(10, (payload-109)/32)

```

> **[Numeric functions · JSONata](http://docs.jsonata.org/numeric-functions#power)**
>
> \## \`$number()\`

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [25 May 2021 13:02 UTC](https://discourse.nodered.org/t/formula-in-expression-mathematics/46216/3 "2021-05-25T13:02:51Z")

</div>

Thanks Nick for this useful info, it works!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 June 2021 13:03 UTC](https://discourse.nodered.org/t/formula-in-expression-mathematics/46216/4 "2021-06-08T13:03:49Z")

</div>

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