Sorry forgot to delete the repetition. This itself should work

=IF(OR(D1="",F1="",),0,IF(D1>F1,4,IF(D1=F1,2,0)))