A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
All IF functions like COUNTIF, SUMIF, AVERAGEIF, MINIF, MAXIF are not friendly with formulas inside them,
To do this, you will have to use AGGREGATE function (Assuming E2 has month, E3 has year, Column A has dates and column B has values)
=AGGREGATE(15,6,B2:B1000/((MONTH(A2:A1000)=E2)*(YEAR(A2:A1000)=E3)),1)