# Formula to cumulatively add and subtract two columns

**URL:** <https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256>\
**Category:** Ask for Help\
**Created:** [February 21, 2023, 5:06pm UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256 "2023-02-21T17:06:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![8pider](https://avatars.discourse-cdn.com/v4/letter/8/8baadc/32.png) [@8pider](https://community.glideapps.com/u/8pider)\
**Post date:** [February 21, 2023, 5:06pm UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/1 "2023-02-21T17:06:30Z")

</div>

Formula to cumulatively add and subtract two columns. I have a column for deposit and another for expenditures. Looking to have another Glide column showing the cumulative balance. Many thanks  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/1/a1e645dad615a2b3c0bc55dfaa2cc03c9946ad4d.png)

---

<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:** [February 21, 2023, 11:41pm UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/2 "2023-02-21T23:41:17Z")

</div>

What do you mean by “cumulatively add and subtract”? Wouldn’t the balance be equal to deposit minus expense?

In that case, you can use a math column.

> **[Glide • Math Column](https://www.glideapps.com/docs/reference/computed-columns/math-column)**
>
> Perform instant calculations using the data in your project.

---

<div class="post-metadata">

**Author:** ![james](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/james/32/71213_2.png) [@james](https://community.glideapps.com/u/james)\
**Post date:** [February 21, 2023, 11:52pm UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/3 "2023-02-21T23:52:22Z")

</div>

I think a couple of rollup columns are needed here

> **[Glide • Rollup Column](https://www.glideapps.com/docs/reference/computed-columns/rollup-column)**
>
> Perform calculations on columns, such as count, average, and sum.

---

<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:** [February 22, 2023, 12:33am UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/4 "2023-02-22T00:33:27Z")

</div>

If it’s for the “total” balance then it makes sense. Have a rollup to sum all deposits, a rollup to sum all expenses, and a math column to calculate the final balance by sum deposits minus sum expenses.

---

<div class="post-metadata">

**Author:** ![8pider](https://avatars.discourse-cdn.com/v4/letter/8/8baadc/32.png) [@8pider](https://community.glideapps.com/u/8pider)\
**Post date:** [February 22, 2023, 8:31am UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/5 "2023-02-22T08:31:32Z")

</div>

Thanks for the response. The rollup and math columns work but provide only one value. Am looking to have a value on each row. Such as the screen shot below  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/f/8f6380d1135cc47cfb784f011dccff2aad5bdcf8.png)

---

<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:** [February 22, 2023, 3:14pm UTC](https://community.glideapps.com/t/formula-to-cumulatively-add-and-subtract-two-columns/58256/6 "2023-02-22T15:14:19Z")

</div>

Do you store any identifiable values in those rows, let’s say a user’s ID or email? It would be a bit difficult and might involve JavaScript, so I want to make sure I understand the full structure here.
