# How to create a cumulative sum of rows in a columns

**URL:** <https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181>\
**Category:** Ask for Help\
**Created:** [August 7, 2022, 9:15pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181 "2022-08-07T21:15:37Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 7, 2022, 9:15pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/1 "2022-08-07T21:15:37Z")

</div>

Hi,

Is there a way in Glide to create a cumulative sum of the rows in a column, like adding up monthly sales ?

1. Jan
2. Jan+Feb
3. Jan+Feb+Mars
4. Jan+Feb+Mars+Apr  
etc…

Thanks!

---

<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:** [August 8, 2022, 12:27am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/2 "2022-08-08T00:27:56Z")

</div>

Take a look at this…

---

<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:** [August 8, 2022, 3:46am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/3 "2022-08-08T03:46:13Z")

</div>

Hola,

We solved a similar case time ago, here you can see it to complement the Darren’s idea:

> [@Running Totals](https://community.glideapps.com/t/running-totals/41596):
>
> Hi Glide Community, Is there a way of calculating running totals in the Glide data editor? I am trying to replicate the below that can be done in Google Sheets but seems to be very difficult in Glide as roll ups are column specific, unless using a relation/lookup/specific array setups. [Screen Shot 2022-05-03 at 7.02.23 PM] [Screen Shot 2022-05-03 at 7.02.37 PM] Is there a way of doing a running total like this? I have tried a different ways with arrays and using the row index but still no …

Saludos!

---

<div class="post-metadata">

**Author:** ![justinjmp](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/justinjmp/32/43205_2.png) [@justinjmp](https://community.glideapps.com/u/justinjmp)\
**Post date:** [August 8, 2022, 2:58pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/4 "2022-08-08T14:58:02Z")

</div>

If you need any help with how this would look like in practice feel free to check out this template here. It was developed to incorporate running totals that you can copy. [Fun Step Tracker Template • Glide](https://www.glideapps.com/templates/fun-step-tracker-xh)

---

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 22, 2022, 5:14pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/5 "2022-08-22T17:14:30Z")

</div>

Since I’m looking for monthly cumulative sums in a year, I have a finite number of rows (12).  
So I decided to do in just in Glide by creating a single value column for each month and multiply it by 12 columns containing 0 or 1. A Math column then gets me the desired cumulative 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:** [August 23, 2022, 12:52am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/6 "2022-08-23T00:52:47Z")

</div>

> [@Killko](#):
>
> and multiply it by 12 columns containing 0 or 1

Can you explain more about this part?

---

<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:** [August 23, 2022, 1:00am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/7 "2022-08-23T01:00:36Z")

</div>

Yes, I’m also curious. Would love to learn a simpler approach.

---

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 23, 2022, 7:26pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/8 "2022-08-23T19:26:06Z")

</div>

Ok, so I start with a Rollup Sum giving me the Revenue for each month.  
I then create 12 Single Value Columns each containing the Revenue for any given month across every row (using the month-1 as index from start).  
Then I create 12 columns with zeroes or ones. ex Jan is 12 ones, Feb is zero followed by 11 ones, and so forth…  
And the cumulative column is created by a math column that sums the multiplication of each month’s revenue column by that month’s zeroes & ones column.

The static zeroes & ones columns act like an if then else in the Math column through multiplication (if zero don’t add that month)…

Obviously doesn’t work for infinite rows, but works very well, within Glide, for Yearly cumulative charts…

Quick example for 5 months…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/f/0f41c2b1f7e20c3e227979267359b61dc6325567.jpeg)

---

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 23, 2022, 8:14pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/9 "2022-08-23T20:14:23Z")

</div>

BTW it would be nifty if one could index a row number in a math column (ie MonthlyRev[2] for March Rev). That would negate the need for the 12 Single Value Columns…

---

<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:** [August 24, 2022, 12:48am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/10 "2022-08-24T00:48:46Z")

</div>

oh, I see… very brute force approach 🙂  
Did you actually look at the solution that I offered? It only requires 6 columns in total.  
It probably looks like there are lots of columns in the video, but most of those are used for other things.

---

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 24, 2022, 1:43pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/11 "2022-08-24T13:43:36Z")

</div>

Actually I was answering another thread (in the wrong place) that used javascript (which I wanted to avoid), and totally missed yours. ☹ It’s very cool!

---

<div class="post-metadata">

**Author:** ![Killko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/killko/32/39538_2.png) [@Killko](https://community.glideapps.com/u/Killko)\
**Post date:** [August 24, 2022, 2:18pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/12 "2022-08-24T14:18:51Z")

</div>

Actually, can’t you remove the last step by making your Relation look like this, starting at row 0 instead of row 1 ?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/6/26ca4ea2adbfcd1d0ed47ccac69e009092621a0e.jpeg)

---

<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:** [August 24, 2022, 4:00pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/13 "2022-08-24T16:00:22Z")

</div>

Yep.  
The only reason I had it the way it was is because the client needed both start of month and end of month values.  
But yes, you’re absolutely correct 👍

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [August 25, 2022, 4:00pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/14 "2022-08-25T16:00:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lucas\_Pires](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lucas_pires/32/64863_2.png) [@Lucas\_Pires](https://community.glideapps.com/u/Lucas_Pires)\
**Post date:** [November 23, 2023, 8:37pm UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/15 "2023-11-23T20:37:03Z")

</div>

Hey guys, I know this topic is already close, and @Darren_Murphy saved us up, but I wanted to bring another insight of how to do it with a few columns, once Glide also improved a lot in the past 1y.

Take a look:

---

<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:** [November 24, 2023, 1:46am UTC](https://community.glideapps.com/t/how-to-create-a-cumulative-sum-of-rows-in-a-columns/46181/16 "2023-11-24T01:46:41Z")

</div>

Yes, query column makes so much easier 😂
