I suspect you could do this with a clever FREQUENCY array but it's too early for that for me I'm afraid...
An alternative would be to use a single column of additional calcs adjacent to your source data which should simplify result matrix calc.
Using your sample...
Formula:
D2:
=1+SUMIF($B$1:$B1,$B2,$C$1:$C1)*(DATEDIF(IFERROR(LOOKUP(2,1/($B$1:$B1=$B2),$A$1:$A1),$A2),$A2,"m")<=6)
copied down to D17
F7:
=LOOKUP(2,1/($B$2:$B17=$E7),$D$2:$D$17)
copied down to F11
the above would generate results of 1,1,1,6 and 3 (I believe last should be 3 and not 2 as per your example).
I have avoided use of Arrays but it should be noted that the LOOKUP approach outlined is not hugely efficient when used in large volume and / or with large precedent ranges.
Were you to sort your source data by Ee and then date the calculation would be simplified.
Bookmarks