简体   繁体   English

我可以在 Google 表格中递归地引用 ArrayFormula 的结果吗?

[英]can I reference the results of an ArrayFormula recursively in Google Sheets?

Say I have a table of indeterminate height, with numerical values in Columns A & B:假设我有一个不确定高度的表,A 列和 B 列中有数值:

A一种 B C C
1 1个 73 73 23 23
2 2个 11 11 58 58
3 3个 ... ... ... ...

If I wanted to calculate the sum of A+B for each row, I could populate all of the results with one formula: =ArrayFormula(A:A+B:B) .如果我想计算每一行的 A+B 之和,我可以使用一个公式填充所有结果: =ArrayFormula(A:A+B:B)

I want to do something similar, but instead of adding A1 to B1 to find C1 , I want to add C1 + B2 to find C2 .我想做类似的事情,但不是将A1添加到B1来查找C1 ,而是想添加C1 + B2来查找C2

I'm wondering if it is possible for ArrayFormula to self-referentially, so I can use the previous result in the next iteration of the formula?我想知道 ArrayFormula 是否可以自引用,以便我可以在公式的下一次迭代中使用以前的结果?

Achieving this with one formula is important in this case, because the table keeps getting longer (it's populated by a live data feed).在这种情况下,使用一个公式实现这一点很重要,因为表格会越来越长(它由实时数据馈送填充)。

At very least, I'd greatly appreciate any help in thinking this through:)至少,我非常感谢任何帮助思考这个问题的人:)

Here's a demo Sheet you can edit. 这是您可以编辑的演示表

it's called running total or cumulative sum ... use:它被称为running totalcumulative sum ...使用:

=INDEX(QUERY(MMULT(TRANSPOSE((SEQUENCE(COUNTA(B:B))<=
 SEQUENCE(1, COUNTA(B:B)))*{C1; B2:B}), 
 SEQUENCE(COUNTA(B:B), 1, 1, )), "offset 1", ))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM