4

I saw a nice solution for the cumulative sum problem here: Cumulative Sum without Script

My question is how do you make this conditional? I mean cumulatively sum only numbers that belong to a certain username (string) in a separate column? I'd like to use arrayformula so cells autofill with data without dragging formula manually. E.g. running total for user A:

User   Amount   Running Total for A
A        1          1
B        2
A        4          5
A        3          8
B        5
A        2          10

1 Answer 1

6

If the data starts in row 2, then try:

=ArrayFormula(IF(A2:A="A",SUMIF(IF(A2:A="A",ROW(A2:A),ROWS(A:A)+1),"<="&ROW(A2:A),B2:B),))

5
  • You are a genius, thank you! Works like a charm.
    – komlos
    Sep 16, 2014 at 15:26
  • Is there a way to make this formula work for all elements of column A?... I.e the conditional Running Total will work for a & b, and any other string a users puts into column A?
    – Xzila
    Dec 10, 2015 at 18:05
  • @Xzila =ArrayFormula(IF(LEN(A2:A),SUMIF(IF(LEN(A2:A),ROW(A2:A),ROWS(A:A)+1),"<="&ROW(A2:A),B2:B),))
    – AdamL
    Dec 10, 2015 at 19:31
  • That totals everything. I meant where it has a separate running total for A, and B in the same column. In the original example the last row for User A should have a Running total of 10, and the last row for User B should have a Running total of 7. I asked a similar question to this one, that I've been trying to figure out: webapps.stackexchange.com/questions/87492/…
    – Xzila
    Dec 10, 2015 at 19:45
  • The newest versions of Google Sheets offer an laternative to this solution, AND also offer a solution for those looking for "a separate running total for A, and B in the same column". The answer by @AdamL to Webapps ArrayFormula to compute running average for groups of rows is an excellent place to start.
    – Tedinoz
    Jan 6, 2021 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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