You can also achieve the intended output using the formula below
Formula
=SUM(FILTER(D1:D, E1:E="YES"))
Sample Input
Output
References:
FILTER
SUM