удалить все в J2: M диапазон
вставить эту формулу в J2 ячейку:
=ARRAYFORMULA(IF(D2:D=TRUE; {
VLOOKUP(A2:A; QUERY(A:H; "select A,sum(H) where C=TRUE group by A"; 0); 2; 0)\
F2:F/VLOOKUP(A2:A; QUERY(A:H; "select A,sum(F) where D=TRUE group by A"; 0); 2; 0)\
VLOOKUP(A2:A; QUERY(A:H; "select A,sum(H) where C=TRUE group by A"; 0); 2; 0)*
(F2:F/VLOOKUP(A2:A; QUERY(A:H; "select A,sum(F) where D=TRUE group by A"; 0); 2; 0))\
I2:I+VLOOKUP(A2:A; QUERY(A:H; "select A,sum(H) where C=TRUE group by A"; 0); 2; 0)*
(F2:F/VLOOKUP(A2:A; QUERY(A:H; "select A,sum(F) where D=TRUE group by A"; 0); 2; 0))}; ))