Having no ideas yet about COUNTIF, I can explain the general comparison like "A1>0" behavior. It tries to convert A1 to number first, if not - converts 0 to a text and compare text values using the sort order.