google-sheetsrangearray-formulasauto-increment

Sheets Arrayformula: increment range size row by row


I am doing a tiny home store overview lists. At the movement sheet I want to sum ONLY the same and previous rows but never mix the results with the future row values.

As I use mostly ARRAYFORMULAs I want to do this also with it. But I cannot find a way to increment the sumif range row by row.

By a drag-down formula it is very easy but in that case the formel will not be extended automatically to all new lines, and it makes the entire workaround just unnecessary complicated. :(

So to being very simple: How can I achieve with an ARRAYFORMULA that also the sumif range is increasing and not always the entire columns are counted?

By a drag-downed references it works well but how to achieve this by Arrayformula:

=SUMIF(A$3:A3,A3,B$3:B3)
=SUMIF(A$3:A4,A4,B$3:B4)
=SUMIF(A$3:A5,A5,B$3:B5)...

This is considering always the entire columns:

=ArrayFormula(SUMIF(A$3:A,A3:A,B3:B))

Any hint is welcome how to change the range row by row and achieve the first pattern with ARRAYFORMULA. Unfortunately I haven't found a solution here: ARRAYFORMULA Auto-Increment

Example link Green is the target and red actually I could made with Arrayformula.


Solution

  • One way to do this is by using the MAP function

    =MAP(A3:A, B3:B, LAMBDA(α, β, SUMIF(A3:α, α, B3:β)))
    

    To display a blank cell when either column is blank, you can use

    =MAP(A3:A, B3:B, LAMBDA(α, β, 
       IF(OR(α = "", β = ""), , SUMIF(A3:α, α, B3:β))
     ))