Count unique values from stat query

starting with some dummy data:

and then two transformations: