Search code examples
google-sheetsarray-formulas

ARRAYFORMULA to SUM previous row column and current row column


https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit?usp=sharing

Shared the above sheet with example. I want an arrayformula to sum the previous rows column and current row column.


Solution

  • In F2 I entered this formula:

    =ArrayFormula(if(row(B2:B)=2, B2, if(len(B2:B)+len(C2:C), mmult(transpose(if(transpose(row(B2:C))>=row(B2:C),if(B2:B<>"", B2:B,0)+(if(C2:C<>"", C2:C,0)*-1), 0)),row(B2:B)^0),)))
    

    But.. in order for this formula to work you will have to write your 'starting' balance in B2. See also the spreadsheet you shared.

    I hope that helps ?