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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Abdullah_Farooq
Contributor
Contributor

Difference between using Count(DISTINCT Field_name1 & Field_Name2) and Count (DISTINCT Field_name1-Field_Name2)

Hi all,

I don't understand why the 2 results in the use of the count expression is showing, hoping you can explain.

I wanted to get a distinct count of the combination of Product and Order Number. I used 2 aproaches for this this:

1) Combining the fields in the count expression as follows - count(distinct Product&OrderNumber). This was not giving the correct results.

2) Creating a new field that combined the Product and Order number and using a count distinct on the new field - count(distinct [Prod-Ord]). Where Prod-Ord = Product & OrderNumber. This is returning the correct answer which is 9.

 

Please see attached screenshot for your reference.

 

QS - Count issue.jpg

 

Labels (3)
2 Replies
G3S
Creator III
Creator III

what is the result if you use:

count(distinct (Product&OrderNumber))

 

Abdullah_Farooq
Contributor
Contributor
Author

Hi there,

I have tried count(distinct (Product&OrderNumber))and its providing a count of 10 - same as count(distinct Product&OrderNumber)

FYI, Load editor script as follows:

Temp:

LOAD * inline [

Customer|Product|OrderNumber|UnitSales|UnitPrice|Prod-Ord

Astrida|AA|1|4|16|AA1

Astrida|AA|7|10|15|AA7

Astrida|BB|4|9|9|BB1

Betacab|CC|6|5|10|CC6

Betacab|AA|5|2|20|AA5

Betacab|BB|1|25| 25|BB1

Canutility|AA|3|8|15|AA3

Canutility|CC|||19|CC

Divadip|CC|2|4|16|CC2

Divadip|DD|3|1|25|DD3

] (delimiter is '|');