So this has been a challenging problem for me. I am trying to get Excel to do an average over a period of time based on what is in the column header.
So here's the column header that I'm talking about:
This is where the (Result) should go.
And then here is my original data (Nut Cost)
So the intent is that I can take the average for Peanuts between 201604 and 201703 based on the header '201604-201703 Avg'.
My thought is to use something like this:
=averageifs('Nut Cost'!$B$2:$P$5,'Nut Cost'!$A$1:$P$1,left('Result'!B2,6):mid('Result'!B2,8,6),'Nut Cost'!$A$2:$A$5,'Result'!$A2)
My other thought is to use something like this:
=SUMIFS('Nut Cost'!$B$2:$P$5,'Nut Cost'!$A$1:$P$1,">="&LEFT('Result'!B2,6),'Nut Cost'!$A$1:$P$1,"<="&MID('Result'!B2,8,6),'Nut Cost'!$A$2:$A$5,'Result'!$A2)
which would be divided by a countif with similar style.