基于参考单元格中的值对 x 个单元格求和

SUM above x Cells based on value in Reference Cell

我目前正在使用 Google 表格。假设:

对于单元格 A10,我想根据 "Reference Cell".

中的值对上述 x 个单元格求和

我该怎么做?

如果从顶部尝试这样:

=SUM(INDIRECT("C1:C"&C10))


如果从底部开始做:

=SUM(INDIRECT("C"&ROW()-1-C10&":C"&ROW()-1))

如果从底部开始,在 A10 中:

=sum(A9:offset(A10,-C10 ,0))

如果从顶部开始,在 A10 中:

=sum(A1:offset(A1,C10-1 ,0))

或自上而下:

=INDEX(QUERY(QUERY(C1:C9, "limit "&C10), "select sum(Col1)"), 2)

和底部:

=INDEX(QUERY(QUERY(C1:C9, "offset "&9-C10), "select sum(Col1)"), 2)

___________________________________________________

也可以作为:

自上而下:

=SUM(QUERY(C1:C9, "limit "&C10))

从底部开始:

=SUM(QUERY(C1:C9, "offset "&9-C10))