Search code examples
google-sheetsarray-formulas

ArrayFormula and sum total


I'm trying to print in column B the sum of all the previous rows of column A. Through the usual formulas this is done like this: enter image description here

B1: = A1
B2: = A2 + B1
B3: = A3 + B2
B4: = A4 + B3

But I need to do this using arrayformula. I tried in A1 to enter this: =ARRAYFORMULA(IF(A1:A4<>"";SUM(INDIRECT("A1:A"&ROW(A1:A4))))) (If I'm not mistaken, in the English version, instead of ";" is used ",")

But it does not work: enter image description here

Tell me, please, how can I solve this problem using arrayformula?


Solution

  • Based on @TomSharpe's answer a while back:

    =ARRAYFORMULA(SUMIF(ROW(A1:A4), "<="&ROW(A1:A4), A1:A4))