Google Sheet formula for cumulative sum with condition

前端 未结 2 1914
庸人自扰
庸人自扰 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:41

    Assuming "Number" in column A and "Counted?" in column B, try in C1

    ={"SUM"; ArrayFormula(if(ISBLANK(B2:B),,mmult(transpose(if(transpose(row(B2:B))>=row(B2:B), if(B2:B="Y", A2:A,0), 0)),row(B2:B)^0)))}
    

    (Change ranges to suit).

    Example

提交回复
热议问题