Distinct Count with Case statement not working
This is a bit of an odd issue, the below calculation ends up adding 1 when rolling up data: Distinct count of ID (if Flag=1)=COUNT(DISTINCT CASE WHEN Flag=1 THEN ID ELSE 0 END) ID Flag Distinct count of ID (if Flag=1) GRAND TOTAL 1 2 456123 1 1 123456 0 1 654321 0 1 Any ideas why this might be happening? This is a mega…