You can also use an "array formula" with AVERAGE in any version, e.g.

=AVERAGE(IF(RangeA=Condition,RangeB))

confirmed with CTRL+SHIFT+ENTER