Hi,

In W2:

=IF(AND(COUNTIF(V1,0),V2=1),U2-LOOKUP(1,0/V1:V$2,U2:U$3),"")

Copy down as required.

Regards