Forum Discussion

wcstarks's avatar
wcstarks
Iron Contributor
Feb 28, 2022
Solved

Average values for each day in a Table, plus two other issues

I have three somewhat related issues. 1) Earlier, Hans Vogelaar helped me modify my original formula to =SUMIF([Date],[@Date],[Carbs]) to calculate the total carbs for each day to simplify referenci...
  • mtarler's avatar
    mtarler
    Mar 04, 2022

    wcstarks So the formula in col M should read:  =AVERAGE([@Glucose]:INDEX([Glucose],MATCH([@Date]-7,[Date],-1)))

    as for what it is doing it is taking the AVERAGE over a range that starts at the Glucose value in THIS ROW (@) and goes to (:) a location based on the INDEX function.  The INDEX is looking in the entire Glucose column and returning the Nth location (based on the result of the MATCH function).  The MATCH is looking for the Day that is -7 from the Date in THIS ROW (@) and it is looking in the entire Date column.

    The final -1 inside that Match just says the dates are sorted from biggest to smallest.

     

Resources