Google Sheets – Average a Row from Last 10 Days to Current Date

formulasgoogle sheetsgoogle-sheets-dates

I am looking for a formula that would automatically average their own row on C3 to C10 based on the last past 10 days from the current day as seen on their right side.
The list doesn't have the weekend because I only need the Monday-Friday work days in the formula.

I've been trying different formulas but the date formula knocks me out

The one I have only counts the last inserted data so it does not depend on the date and it's not accurate for a more "recent" past 10-day data average.

=iferror((sum(INDIRECT(ADDRESS(row(),(max(filter(column(D3:3),len(D3:3)))))):indirect(ADDRESS(row(),(max(filter(column(D3:3),len(D3:3))))-9))))/10,"-0-")

Here's my trial with the layout

I feel that it is possible but I'm out of ideas. Hope someone can help with some solutions?

Best Answer

Since you only have 8 entries, I didn't go for a column-length array formula. I replaced your C3 formula with the following and dragged down:

=ArrayFormula(SUM(QUERY(TRANSPOSE({$D$2:$2;D3:3}),"Select Col2 Where Col1 > date '"&TEXT(TODAY()-14,"yyyy-mm-dd")&"'"))/10)

What this does is form a virtual array between the curly brackets {} of the static date row with the underneath data for the current row. These two rows are turned to columns in memory with TRANSPOSE. Then a QUERY is performed on this two-column array to limit the array only the data matching two weeks ago or greater. This limited data set is then SUMmed and divided by 10 to get your final average.