# Math and Function Node

**URL:** <https://forums.losant.com/t/math-and-function-node/1907>\
**Category:** Help\
**Tags:** workflow\
**Created:** [June 20, 2019, 5:46pm UTC](https://forums.losant.com/t/math-and-function-node/1907 "2019-06-20T17:46:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Betke](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@Jonathan\_Betke](https://forums.losant.com/u/Jonathan_Betke)\
**Post date:** [June 20, 2019, 5:46pm UTC](https://forums.losant.com/t/math-and-function-node/1907/1 "2019-06-20T17:46:40Z")

</div>

In our use case, we allow end users to create their own formula for transposing readings coming in from a device into the unit of measure they want to see. For instance, our device can measure milliamps 0 - 24. This device can be set up to monitor a tank of water with a pump attached. The user can create a formula to transpose the reading of say 7 milliamps from the device, into feet of water that is in the tank.

Why can’t the workflow evaluate a string formula? The Math node can’t do it, and the Function node, which is supposed to support JavaScript can’t even run the eval(string) function.

How do I get a string (“5 \* 2.1625 - 8.65”) to evaluate in a workflow?

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [June 20, 2019, 7:26pm UTC](https://forums.losant.com/t/math-and-function-node/1907/2 "2019-06-20T19:26:43Z")

</div>

Hi @Jonathan_Betke,

The platform’s current functionality does not support evaluating a string formula. I will make a feature request with our engineers, and follow up with any ideas we may come up with to solve this problem.

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [June 20, 2019, 8:25pm UTC](https://forums.losant.com/t/math-and-function-node/1907/3 "2019-06-20T20:25:49Z")

</div>

@Jonathan_Betke,

One crazy idea I just had. You _might_ be able to use something like this:

> **[jwadhams/json-logic-js](https://github.com/jwadhams/json-logic-js)**
>
> Build complex rules, serialize them as JSON, and execute them in JavaScript - jwadhams/json-logic-js

It’s a library that allows you to create a JSON representation of logic. Being that’s its JSON, you could evaluate it within the workflow engine. Overall, depending on complex the customers’ logic is, you may be able to come up with your own standard. But, this may be a lot of work to solve a simple problem.

Anyway, just letting you know the idea I had. Now that we have the feature in the system we may come up with the right way of doing it in the future.

---

<div class="post-metadata">

**Author:** ![Vander\_Maziero](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/vander_maziero/32/3428_2.png) [@Vander\_Maziero](https://forums.losant.com/u/Vander_Maziero)\
**Post date:** [May 5, 2021, 8:38pm UTC](https://forums.losant.com/t/math-and-function-node/1907/4 "2021-05-05T20:38:57Z")

</div>

Hey,

Any progress on this feature, in our use case, we encounter the same problem, to evaluate a string as an expression.

---

<div class="post-metadata">

**Author:** ![Vander\_Maziero](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/vander_maziero/32/3428_2.png) [@Vander\_Maziero](https://forums.losant.com/u/Vander_Maziero)\
**Post date:** [May 7, 2021, 3:32pm UTC](https://forums.losant.com/t/math-and-function-node/1907/6 "2021-05-07T15:32:39Z")

</div>

Hi,

I used this code, which allows to perform basic operations and implemented a custom node to Evaluates the result of the String arithmetical expression.

> **[devrafalko/string-math](https://github.com/devrafalko/string-math)**
>
> Evaluates the result of the String arithmetical expression

I share here the nodes that can be useful.

[calc-develop.flow](https://forums.losant.com/uploads/short-url/7IkhymWkSRdrKmyPyYEsvPfOmXH.flow) (10.9 KB)  
[matheval-develop (1).node](https://forums.losant.com/uploads/short-url/vWh5qh92qSM9NLCwzYz7UBsSgYq.node) (7.0 KB)

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [May 7, 2021, 3:44pm UTC](https://forums.losant.com/t/math-and-function-node/1907/7 "2021-05-07T15:44:23Z")

</div>

@Vander_Maziero,

Thank you so much for sharing your flow and node with the community!

I did make a new feature request for this feature, so I will be sure to follow up with you as I learn more about it from our engineering team.

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [July 20, 2021, 3:36pm UTC](https://forums.losant.com/t/math-and-function-node/1907/11 "2021-07-20T15:36:03Z")

</div>

Hello @Vander_Maziero,

I wanted to reach out to you and mention that we did just release a new [Format Helper](https://docs.losant.com/workflows/accessing-payload-data/#format-helpers) called `evalExpression`, which evaluates a string as an expression.

You can check it out in the documentation I’ve linked, and you can find out more about our latest release in [our blog](https://www.losant.com/blog/platform-update-snmp-nodes-on-disk-workflows).

Thanks,  
Heath
