Hi ,
Going by your workbook , you should use the following :
=IFERROR(AVERAGEIFS($C$2:$C$24,$A$2:$A$24,A3,$B$2:$B$24,"D"),AVERAGEIFS($C$2:$C$24,$A$2:$A$24,A3,$B$2:$B$24,"R1"))
so that you do not need to select the range individually for each job code.
Narayan