=(NB.SI.ENS(INDIRECT($D5);"am";INDIRECT($C5);">="&FIN.MOIS(AI$2;-1)+1;INDIRECT($C5);"<="&FIN.MOIS(AI$2;0)))/2 +
(NB.SI.ENS(INDIRECT($D5);"aa";INDIRECT($C5);">="&FIN.MOIS(AI$2;-1)+1;INDIRECT($C5);"<="&FIN.MOIS(AI$2;0)))/2 +
NB.SI.ENS(INDIRECT($D5);"A";INDIRECT($C5);">="&FIN.MOIS(AI$2;-1)+1;INDIRECT($C5);"<="&FIN.MOIS(AI$2;0))