John DeMalia Jr.
John DeMalia Jr.

Reputation: 21

Average over last 7 days formula in google sheets

My 1-year-old son was just diagnosed with Type 1 Diabetes, and I am trying to create a spreadsheet to track his sugar levels etc. I have the dates in column A, and his blood sugar levels in column C. I have been trying for the last couple days to figure out how to get his average blood sugar levels for the last 7 days, and just keep getting errors. I have searched google extensively, and have found some similar examples, but can never seem to get them to work.

This is what I have at the moment, but I get a Divide by zero error.

=averageif(A7:A, ">=" & (TODAY()-6),C7:C)

I would greatly appreciate any help with this.

Upvotes: 2

Views: 3165

Answers (2)

player0
player0

Reputation: 1

try:

=AVERAGEIFS(C2:C, A2:A, "<="&TODAY(), A2:A, ">="&TODAY()-6)

0

Upvotes: 2

player0
player0

Reputation: 1

try:

=AVERAGE(IFNA(QUERY(A2:C, 
 "select C 
  where A <= date '"&TEXT(TODAY(),   "yyyy-mm-dd")&"'
    and A >= date '"&TEXT(TODAY()-6, "yyyy-mm-dd")&"'", 0)))

0

Upvotes: 1

Related Questions