Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For this question, I've created a Google Apps Script function, that calculates the cumulative sum of a range. Martin Hawksey on Google+ made a comment about a more efficient way of calculating the cumulative sum:

function cumulativeSum(array){
  var output = [];
  for (i in array){
    if(i==0) {
      if (array[i].length > 1) throw ("Only single column of data");
    } else {
      output.push([output[i-1][0] + array[i][0]]);
  return output;

My question is: can this be achieved with the usage of formula's?

share|improve this question
Apologies for a very late answer, I just saw he thread in "Related" on the right. – AdamL Jun 30 '13 at 10:22
up vote 17 down vote accepted



Example of Cumulative Sum

The numbers in the green circle are the ones being summed, the ArrayFormula is populating all the others based on the cell it was pasted into, in this example I pasted in A11, B1, and C1 to show its effect.

This spreadsheet that I made a while ago attempts to explain how MMULT can be used for these sort of problems, and it also demonstrates the SUMIF solution on one of the sheets, which can (and probably should) be used for special cases like the one in this question.

share|improve this answer
I took this formula once (I think it was yours) on the Google Forum: SUMIF(ROW(A:A);"<"&ROW(A:A)), that didn't work. This one does. – Jacob Jan Tuinstra Jun 30 '13 at 11:56
Is there a program that you used to create that fancy screenshot with the drop shadow? – ComputerLocus Jul 3 '13 at 22:38
The image in the answer was edited in by another member: +Xavier Casto – AdamL Jul 4 '13 at 0:10
@Fogest, I used a product called "Snagit" find out more about at techsmith.com/download/snagit – Xavier Casto Jul 5 '13 at 15:49
@XavierCasto Oh, I've used this a LONG time ago, didn't remember it having this, though it was a long time ago. Thanks for the reply though, I like products by techsmith. – ComputerLocus Jul 5 '13 at 15:50

Assuming you want:

  Row | A | B | B's formula
   1  | 1 | 1 | =1     (or =A1)
   2  | 2 | 3 | =1+2   (or =A2+B1)
   3  | 3 | 6 | =1+2+3 (or =A3+B2)


Then you can use:=sum($A$1:A1) where A1 is the start of numbers to sum. Put that formula in B1 (or where ever you want) and fill it down, and it will sum all cells up to and including the row you're on. Alternately, you can use the =Ax+Bx-1 (x = current row, data in A, cumulative sum in B) format from the "B's formula" section above.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.