# Solve math formula that is currently text in a cell using a button? (trying to make a calculator)

**URL:** <https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528>\
**Category:** Ask the Community\
**Created:** [July 13, 2021, 5:23am UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528 "2021-07-13T05:23:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Moritz](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/aaron_moritz/32/21095_2.png) [@Aaron\_Moritz](https://connect.superhuman.com/u/Aaron_Moritz)\
**Post date:** [July 13, 2021, 5:23am UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/1 "2021-07-13T05:23:57Z")

</div>

I’m not sure if I’m missing something obvious or if this isn’t a function, but I’d like to be able to solve a math equation, written in the form of say something like: 9+(5\*2)/10-2 that has been entered into a table as text.

If I enter that into a formula directly, it renders the answer as 8. But if I have it entered into a cell of a table, all I can do is call up the row.column, and it displays “9+(5\*2)/10-2”, but I can’t solve it

This came up when I was trying to make a calculator template I could paste into docs when convenient. Realized after I built it to do some basic functions that it would be very hard to render complex formulas like the eg above. But also that it would be fairly easy if I could just use the buttons to type into a cell and then another button to solve the equation when I’m done.

here’s the semi functioning calc I’ve built

https://coda.io/embed/jCgxLzHC7-/_suI1K?viewMode=embedplay

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [July 13, 2021, 9:20am UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/2 "2021-07-13T09:20:56Z")

</div>

With some black magic, everything’s possible 🙂

https://coda.io/embed/zziQAJd8UX/_su9dH?viewMode=embedplay&hideSections=true

It’s not obvious though, and not a recommended solution. This takes a button, extracts its code and replaces a piece of that code with the expression. Then creates an Action object out of that new adjusted code and sets it on another button. Please mind that the code uses slightly different notation than Coda formulas, e.g. you cannot reference rows and columns like you’d do in Coda formula language. For literal numbers it works though.

---

<div class="post-metadata">

**Author:** ![Johg\_Ananda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/johg_ananda/32/13930_2.png) [@Johg\_Ananda](https://connect.superhuman.com/u/Johg_Ananda)\
**Post date:** [July 13, 2021, 11:16am UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/3 "2021-07-13T11:16:47Z")

</div>

@Paul_Danyliuk could you add some illumination on `_Merge()` and `_Deref_Object()`? It seems like these help create _raw_ Coda notation, which is why they don’t update/reference as usual, correct?

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [July 13, 2021, 11:58am UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/4 "2021-07-13T11:58:37Z")

</div>

I haven’t explored `_Merge()` to its fullest (i.e. what’s its intended use). All I know is that it can return an object that describes any provided Coda value, reference, control etc. By adding a blank text line `+ ""` it converts that object to its text representation, which is JSON.

Then you can manipulate that JSON as regular text, e.g. replace parts of an action formula, manipulate list nesting level, manipulate character and paragraph styling data etc.

Then you can turn JSON back into an object using `ParseJson()`. However Coda won’t convert objects to “meaningful” Coda objects unless they are nested at least one level down. Hence what I’m doing is that I’m making an object out of:

```auto
{"o": <actual object here>}

```

and then extracting the value of key `"o"` using `_Deref_Object(object, key)`, which is again a control, an action, a reference etc.

---

<div class="post-metadata">

**Author:** ![Aaron\_Moritz](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/aaron_moritz/32/21095_2.png) [@Aaron\_Moritz](https://connect.superhuman.com/u/Aaron_Moritz)\
**Post date:** [July 13, 2021, 4:20pm UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/5 "2021-07-13T16:20:17Z")

</div>

This is amazing, thanks. I had to read your comment like five times but I get the shape of how it works, but I think I do now. Very interesting for sure. I get why it’s not a recommended solution because it seems like it would break pretty easily if something changes in how buttons are coded

Still probably gonna use it for now though for my personal little calculator until it breaks. I was surprised there was no simple calculator template out there, but i guess most people would just open the one on their computer. I liked the idea though of having the calc template I could bring in anywhere I was in coda, and have the answers as data that I could throw into whatever doc I’m in more easily than the windows calculator

Thanks for the brain stretch and temp solution!

---

<div class="post-metadata">

**Author:** ![cylinder\_volume-calculator](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/cylinder_volume-calculator/32/50290_2.png) [@cylinder\_volume-calculator](https://connect.superhuman.com/u/cylinder_volume-calculator)\
**Post date:** [October 7, 2026, 7:42pm UTC](https://connect.superhuman.com/t/solve-math-formula-that-is-currently-text-in-a-cell-using-a-button-trying-to-make-a-calculator/24528/6 "2026-10-07T19:42:47Z")

</div>

For a reusable calculator, I’ve found it helps to structure the doc with separate input columns for each variable (radius, height) and a formula column that computes the result directly — that keeps the math explicit instead of trying to parse text. When I added a geometry section to a project doc, I sanity-checked my πr²h results against a dedicated [volume of cylinder](https://www.cylindervolume-calculator.com/) reference with worked examples. Keeping inputs and formula columns separated like this also makes the calculator easy to duplicate into other docs.
