Google Sheets – Conditional Cumulative Sum Using Arrayformula in Google Sheets

formulasgoogle sheets

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

Best Answer

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),))