roasthawg,
Ah, ok. That makes things much more complicated. In order to use only formulas, I had to use the MCONCAT function which is provided by the Morefunc add-in.
Attached is version 2. Column M is a helper column. In cell M2 and copied down is this formula:
=LOOKUP(2,1/($A$1:$A1<>$A2),ROW(INDIRECT("1:"&ROWS($A$1:$A1))))
Then, in cell J2 and copied down to J10, then copied to cells K2:K10 is this array formula:
=IF(COUNTIF($B$1:INDEX($C$1:$C1,$M2),$B2)=0,"",SUMPRODUCT(SUMIF($B$1:INDEX($C$1:$C1,$M2),INDEX(TRIM(MID(SUBSTITUTE(TRIM(MCONCAT(IF($B$1:INDEX($B$1:$B1,$M2)=B2,$C$1:INDEX($C$1:$C1,$M2),IF($C$1:INDEX($C$1:$C1,$M2)=B2,$B$1:INDEX($B$1:$B1,$M2),""))," "))," ",REPT(" ",99)),99*(ROW(INDIRECT("1:"&COUNTIF($B$1:INDEX($C$1:$C1,$M2),B2)))-1)+1,99)),),$D$1:$E1))/SUM(COUNTIF($B$1:INDEX($C$1:$C1,$M2),INDEX(TRIM(MID(SUBSTITUTE(TRIM(MCONCAT(IF($B$1:INDEX($B$1:$B1,$M2)=B2,$C$1:INDEX($C$1:$C1,$M2),IF($C$1:INDEX($C$1:$C1,$M2)=B2,$B$1:INDEX($B$1:$B1,$M2),""))," "))," ",REPT(" ",99)),99*(ROW(INDIRECT("1:"&COUNTIF($B$1:INDEX($C$1:$C1,$M2),B2)))-1)+1,99)),))))
It is very long because it is very complex. You needed to get teams that had played against the current row's teams prior to the current row's date, and then average all of their scores together. This formula does that and is the only way I can think of to do so without resorting to VBA (a UDF or macro). It does however provide the correct results for team "b" and the corect results for team "c" and does so using the logic described in your most recent post.
You can hide column M if you want.
Bookmarks