Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
simonroschu
Contributor II
Contributor II

How to only count unique subjects for each id?

Hi everyone, 

i am working on some data that look like this: 

ID

Subject

1

A

1

A

1

B

2

A

2

C

3

C

4

A

4

A

4

A

4

C

 

I want to count the subjects, but only the unique ones for each ID. In this example the result should be 7 (the ones with the red font).

Any clue ? Thanks for helping,

Simon 

Labels (1)
4 Replies
tresesco
MVP
MVP

Try:

=Sum(Aggr(Count(DISTINCT Subject), ID))

Vegar
MVP
MVP

Is it correct to assume that you want to count the distinct unique combinations of Subect and ID? If so then you could use this calculation.

=count(distinct Hash128(ID,Subject))

simonroschu
Contributor II
Contributor II
Author

Yes, thats correct. 

I tried your calculation and it works. I really hope its also working for bigger data

simonroschu
Contributor II
Contributor II
Author

Thank you. It seems like its giving me the right result.