Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
clare
Contributor
Contributor

why count work as count distinct

hello experts

i am working with qlik sense enterprise 2021 May,  I found count(申请人id) worked as count(distinct 申请人id) in my App 674 which three tables join, i am so confused ..... but it works correct in App 674(1) which only two tables join.   is this related to three tables join or maybe it is a feature or maybe other reason...  please help ,  Detail please check attachment Apps and pictures . thank you

Labels (1)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

An aggregation on a key field is not well defined, unless you use the distinct clause: If you have several tables, the engine doesn't "know" which table to use when making the count. The different tables will return different values. 

Take a look at "Aggregation of key fields" on https://help.qlik.com/en-US/sense/May2022/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunc....

If you don't want a count distinct, you need to make a copy of the key field, and use this for your count.

We did change the behaviour a couple of versions back, because we had bugs in the logic - bugs that made the behaviour inconsistent.

But now it is consistent: If the field is a key between three or more tables, a count will always return the count distinct.

View solution in original post

2 Replies
hic
Former Employee
Former Employee

An aggregation on a key field is not well defined, unless you use the distinct clause: If you have several tables, the engine doesn't "know" which table to use when making the count. The different tables will return different values. 

Take a look at "Aggregation of key fields" on https://help.qlik.com/en-US/sense/May2022/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunc....

If you don't want a count distinct, you need to make a copy of the key field, and use this for your count.

We did change the behaviour a couple of versions back, because we had bugs in the logic - bugs that made the behaviour inconsistent.

But now it is consistent: If the field is a key between three or more tables, a count will always return the count distinct.

clare
Contributor
Contributor
Author

Thank you Henric~