I wouldn't do it with the if OR with set analysis. For performance, I'd suggest setting a counter in the script load like this:
if(Date1 = Date2, 1) as "Dates Equal Counter",
Or possibly more generally useful, as it could be used as a chart dimension, for instance, to only show IDs where the dates are equal:
if(Date1 = Date2, ID) as "Dates Equal ID",
Then experiment to find out which of the following is faster:
count("Dates Equal ID")
sum("Dates Equal Counter")
Different QlikView versions have differed in that regard.