This is one approach of the issue. Adjust the formula to your actual ranges
The formula in C4 cell
=FILTER(G3:G14,BYROW((H3:K14="Yes")*(H2:K2=D2),LAMBDA(x,SUM(x))))