Home > Mobile >  Running SUM with ARRAYFORMULA
Running SUM with ARRAYFORMULA

Time:04-04

I have a list of values per day and I want, for each day, to sum the last 7 days using an array formula. Basically, I want to use this formula

=SUM(A1:A7) inside an ARRAYFORMULA but I can't get it to work.

Theoretically it should look something like

ARRAYFORMULA(SUM(B1:B:B7:B)) which of course doesn't work.

Note: the formula must be at the top row, since new data is added daily so row 2 of today will become row 3 tomorrow. The solution therefor must fit the top cell of the column.

I created a sheet with an example. Col A is dates, Col B is values Col C is the manual sum of the 7 days just as a reference

enter image description here

Or better this to include a header:

=ArrayFormula(if(B:B="",,if(isnumber(B:B),sumif(row(B:B),"<"&row(B:B) 7,B:B)-sumif(row(B:B),"<"&row(B:B),B:B),"Running Total")))
  • Related