Google Sheet formula for cumulative sum with condition

前端 未结 2 1916
庸人自扰
庸人自扰 2021-01-27 06:20

I have a Google Sheet with the following layout:

  Number |  Counted?  |  Cumulative Total
    4    |     Y      |         4
    2    |            |         6
           


        
2条回答
  •  遥遥无期
    2021-01-27 06:36

    Try this in C2 and copy down:

    = N(C1) + A2 * (B2 = "Y")
    

    Update

    Doesn't seem to work with SUMIFS, but there is a very slow matrix multiplication alternative:

    =ArrayFormula(MMult((Row(2:1000)>=Transpose(Row(2:1000)))*Transpose(A2:A1000*(B2:B1000="Y")), Row(2:1000)^0))
    

提交回复
热议问题