The average is given by
Code:
=AVERAGEIF($A$1:$A$15,"=6",$B$1:$B$15)
(you can refer to a cell value instead of hard-coding the value)
Summing values in N
Code:
=SUMPRODUCT(($M$1:$M$10="gen")*($N$1:$N$10))
Although you asked for a count the result you gave is the sum of the values.