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

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

Finding Count of Field against another field distinct values(Ignoring duplicates)

Hi Experts,

I want your help in finding the distinct number(count) of IDs where table is having 2 coloumns ID and Order,
1)Order values considered for distinct ID if those are different.
2)If the ID and Order combination is single value needs to be ignored
3)If the ID and Order combination repeats then those needs to be ignored.

ID                  Order
ghi123         449
ghi123         393
lmn123       543
xyz123         999
xyz123         999
xyz123         999
pqr123        678
pqr123        445
pqr123        877
abc123       436
abc123       436

After applying above conditions ID count should be 2 (ghi123, pqr123) as the values are differed.

I tried with Chart expression "Sum(Aggr(Count(distinct Order)>1,ID))" like this but result are not correct.

Please do help me to solve this issue? Thanks a ton in advance.

Labels (3)
10 Replies
sunny_talwar

Your expression is acting like an if statement within the Sum(Aggr())

Count(distinct Order) > 1 gives -1 when true and 0 when false per id.... and then you add them up.... The better way to code this is

Sum(Aggr(If(Count(DISTINCT Order) > 1, 1, 0), ID))