带有条件的累积总和的 Google Sheet 公式 [英] Google Sheet formula for cumulative sum with condition

查看:35
本文介绍了带有条件的累积总和的 Google Sheet 公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下布局的 Google 表格:

I have a Google Sheet with the following layout:

  Number |  Counted?  |  Cumulative Total
    4    |     Y      |         4
    2    |            |         6
    9    |     Y      |        15
   ...   |    ...     |        ...

Cumulative Total 列中的第一个单元格使用以下公式填充:

The first cell in the Cumulative Total column is populated with this formula:

=ArrayFormula((SUMIF(ROW(C2:C1000),"<="&ROW(C2:1000),C2:C1000)

但是,这会计算数字"列中的所有行.如何使累积总计仅计算 Counted? 单元格为 Y 的行?

However this counts all rows in the 'Number' column. How can I make the Cumulative Total only count rows where the Counted? cell is Y?

推荐答案

C2 中试试这个并复制下来:

Try this in C2 and copy down:

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

<小时>

更新

似乎不适用于 SUMIFS,但有一个非常慢的矩阵乘法替代方案:

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))

这篇关于带有条件的累积总和的 Google Sheet 公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆