# Math Column with Dynamic Formula

**URL:** <https://community.glideapps.com/t/math-column-with-dynamic-formula/72334>\
**Category:** Ask for Help\
**Created:** [April 5, 2024, 11:50am UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334 "2024-04-05T11:50:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darko\_Vukoje](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darko_vukoje/32/73227_2.png) [@Darko\_Vukoje](https://community.glideapps.com/u/Darko_Vukoje)\
**Post date:** [April 5, 2024, 11:50am UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/1 "2024-04-05T11:50:49Z")

</div>

Hi,

I am developing a small app for tennis league matches.  
Every match calculates how many points are earned by winner and loser.

e.g. formula for winner is:  
(gamesLost+(gameLost-gameWon)\*0.2)\*coeficijent

It works nice, but I need to have formula configurable through app settings (probably stored in appSettings table as a string).

As template column enables dynamic content setting from any other column, math column does not allow that.

Is there any way I can achieve wanted? (To have text formula stored in appSettings to evaluate to points won).

Would regex help here?

Thanks,  
Darko

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 5, 2024, 12:07pm UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/2 "2024-04-05T12:07:43Z")

</div>

Interesting use case.  
I think you could probably use the `eval()` function inside a JavaScript column. Just be aware that the JavaScript column always returns a string, so you would need a math column to coerce the result to a Number.

---

<div class="post-metadata">

**Author:** ![Darko\_Vukoje](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darko_vukoje/32/73227_2.png) [@Darko\_Vukoje](https://community.glideapps.com/u/Darko_Vukoje)\
**Post date:** [April 5, 2024, 1:03pm UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/3 "2024-04-05T13:03:28Z")

</div>

works nice. Thank you @Darren_Murphy

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 5, 2024, 11:59pm UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/4 "2024-04-05T23:59:00Z")

</div>

Just curious, can you talk through the full setup with the eval function as Darren mentioned? Do you have a template column with the formula and reference it in the JavaScript snippet?

---

<div class="post-metadata">

**Author:** ![Darko\_Vukoje](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darko_vukoje/32/73227_2.png) [@Darko\_Vukoje](https://community.glideapps.com/u/Darko_Vukoje)\
**Post date:** [April 13, 2024, 6:06am UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/5 "2024-04-13T06:06:21Z")

</div>

The latest update is : it does work only on iPhone devices, several users have reported it doesn’t work on various Android devices, so I switched back to hard coding the formula in the column.

My evaulation column is very simple : return eval(p1);

Thanks

---

<div class="post-metadata">

**Author:** ![Darko\_Vukoje](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darko_vukoje/32/73227_2.png) [@Darko\_Vukoje](https://community.glideapps.com/u/Darko_Vukoje)\
**Post date:** [April 13, 2024, 9:05am UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/6 "2024-04-13T09:05:39Z")

</div>

I have a template column for formula that is being filled with real values, so the end resuls is a string e.g. 10+(20\*0.3) which js evaluates to a real value. But for some reason, it doesn’t go through on Android devices and returns 0

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [April 14, 2024, 3:43pm UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/7 "2024-04-14T15:43:48Z")

</div>

> [@Darko\_Vukoje](#):
>
> string e.g. 10+(20\*0.3) which js evaluates to a real value

Hola Darko,

Just a little warning using _eval()_:

Instead of using a value with decimals to get a result, I would change it to its equivalent as a fraction in order to avoid problems with device’s regional settings.

I mean, instead of `10+(20*0.3)`, I’d use: `10+(20*3/10)`

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/7/f77b9370919e45ca664ed1f62487e8bd8a582498.png)

A device using Spanish as its regional setting expects a comma (“,”) as the decimal point, not a period (“.”) for example.

Feliz domingo!

---

<div class="post-metadata">

**Author:** ![Darko\_Vukoje](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darko_vukoje/32/73227_2.png) [@Darko\_Vukoje](https://community.glideapps.com/u/Darko_Vukoje)\
**Post date:** [April 15, 2024, 8:34am UTC](https://community.glideapps.com/t/math-column-with-dynamic-formula/72334/8 "2024-04-15T08:34:19Z")

</div>

Wow, what a catch maestro! THANKS !
