I came up with a non-array solution (I think) but requires two "dummy columns"
In G2 dragged down
=COUNTIF($C$2:$D2,C2)
In H2 dragged down
=COUNTIF($C$2:$D2,D2) You can hide these two columns if you like.
Then with a unique list of teams in J2:J21, In K2;
=SUMPRODUCT(--($C$2:$D$381=J2),--($G$2:$H$381>(COUNTIF($C$2:$D$381,J2)-5)), $E$2:$F$381)
See attachment
Bookmarks