Try this in J24 and drag down:

=SUMPRODUCT(--($I$5:$I$21=B24),$F$5:$F$21,$G$5:$G$21,$J$5:$J$21)/1000