superstacker007
superstacker007

Reputation: 35

SUM above x Cells based on value in Reference Cell

I am currently using Google Sheets. Suppose:

For Cell A10, I want to SUM the above x cells, based on the value in my "Reference Cell".

How can I do this?

Upvotes: 1

Views: 94

Answers (3)

player0
player0

Reputation: 1

or from top:

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

0

and bottom:

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

enter image description here

___________________________________________________

also doable as:

from top:

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

from bottom:

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

Upvotes: 0

user11982798
user11982798

Reputation: 1908

enter image description here

If from bottom, in A10:

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

if from top, in A10:

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

Upvotes: 1

player0
player0

Reputation: 1

try like this if from top:

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

0


if from the bottom do:

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

enter image description here

Upvotes: 0

Related Questions