Look at SUMIF and COUNTIF functions, then set up your average
calculation by dividing the result of the SUMIF by the COUNTIF.