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: 
maniram23
Creator II
Creator II

count of distinct

i have a field called period. i want count to the distinct count in script level . i don't want create in UI level test object.

1 Solution

Accepted Solutions
PrashantSangle

Hi,

Yes, but it is aggreated function for that you required Group by clause.

Check below test script ;

t1:
LOAD * INLINE [
    no,ID
    23,1
    43,1
    54,2
    1000,2
    99,1
];

t2:
LOAD count(no) as count_no,
ID
Resident t1
Group by ID
;

DROP Table t1;

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

6 Replies
amit_saini
Master III
Master III

Mani,

try this:

Count(DISTINCT CustomerCode)

or

sum(aggr(count( distinct MonthName(Date)), CustomerCode ))

or

=COUNT(TOTAL<Customer> DISTINCT Product)

Thanks,

AS

PrashantSangle

Hi,

If you need to count in script

then in script add count(fieldname) as count_fieldName,

Note : Count is aggreated function for that you required group by clause.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
maniram23
Creator II
Creator II
Author

hi

count works in script level ?

PrashantSangle

Hi,

Yes, but it is aggreated function for that you required Group by clause.

Check below test script ;

t1:
LOAD * INLINE [
    no,ID
    23,1
    43,1
    54,2
    1000,2
    99,1
];

t2:
LOAD count(no) as count_no,
ID
Resident t1
Group by ID
;

DROP Table t1;

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
amit_saini
Master III
Master III

yes you can , but it should be aggr() function.

Thanks,
AS

anbu1984
Master III
Master III

If you need distinct count of a field, you can try like this

t1:
LOAD * INLINE [
no,ID
23,1
43,1
54,2
1000,2
99,1
]
;

Load Count(DISTINCT ID) Group by Key;
Load 1 As Key,ID Resident t1;