Home > Software engineering >  ARRAYFORMULA – Create a running balance – Add cell in previous row cell in same row
ARRAYFORMULA – Create a running balance – Add cell in previous row cell in same row

Time:02-04

Hopefully the title is descriptive enough. I want to create this calculation in ARRAYFORMULA so that I don't have to keep dragging/copy/pasting what would otherwise be a simple formula.

Here's what I have so far. It seems to work for the first two rows, and then it doesn't anymore:

=ArrayFormula({"Balance";if(isblank(D2:D),"",R1:R Q2:Q)})

Link to a sample sheet: https://docs.google.com/spreadsheets/d/1OPJ4Zo108mO-LW8DeKrZRrXzHxt9u2qLhnqXWUX31YU/edit?usp=sharing

Any help is very appreciated!

CodePudding user response:

See my newly added sheet ("Erik Help"), cell R1:

=ArrayFormula({"Balance"; IF(Q2:Q="",,SUMIF(ROW(Q2:Q),"<="&ROW(Q2:Q),Q2:Q))})

This basically says, "Leave a header. Underneath, if a corresponding cell in Col Q is blank, leave Col R blank. Otherwise, give the SUM of all rows up to and including the current row."

  •  Tags:  
  • Related