I have a Google Sheet with the following layout:
Number | Counted? | Cumulative Total 4 | Y | 4 2 | | 6
Try this in C2 and copy down:
C2
= 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))