sumproduct with offset
Posted by greg on January 03, 2002 12:17 PM
I would like to take various-sized averages of selected rows of a matrix.
Say I have a matrix D2:BI453 whose columns represent days and rows represent IDs.
I want some variable number of contiguous days average of specific IDs.
When I wanted only 1 day, it was easy (though not elegant): I entered a 1 in column C on the row of each ID to include, then used SUMPRODUCT(C2:C453,BI2:BI453)
Then someone asked for 7 days. So:
(SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,0)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-1)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-2)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-3)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-4)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-5)) +
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,-6))) /7
Now the number of days to average changes frequently. I tried
SUMPRODUCT(C2:C453,OFFSET(Blocks!BI2:BI453,0,0, 453, 7)) but get #VALUE!
How can I do this?