Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
akmughal
Contributor II
Contributor II

Count if equal 1

Hi there,

I'm not sure how to get distinct Group ID count if there is a single entry of a client.

So, in below example I wanted to count distinct group id of all clients who have just one entry date.

Client IDEntry DateExit DateGroup ID
27/1/20208/20/2020100
37/1/20208/20/2020100
810/1/202012/20/2020101
105/1/20206/20/2020102
107/1/20208/20/2020102
117/1/20208/20/2020102

 

Result = 3

I'm trying this expression but does not work

=Count(aggr(if(count([Client ID]) = 1,[Group ID]),[Group ID]))

Could someone help how to write correct statement?

Thank you,

akmughal

 

 

 

1 Solution

Accepted Solutions
albertovarela
Partner - Specialist
Partner - Specialist

Great to hear @akmughal ! Please accept as solution so the thread can be closed.

View solution in original post

13 Replies
dwforest
Specialist II
Specialist II

For the example you cited, you can use set analysis

Count({<[Exit Date]={"*"}>} [Group ID])

 

 

albertovarela
Partner - Specialist
Partner - Specialist

How about:    count(distinct {$<[Group ID]={"=aggr(count([Client ID]),[Group ID])=1"}>} [Group ID])

albertovarela
Partner - Specialist
Partner - Specialist

Actually, I think the distinct qualifier can be removed as we are already evaluating the distinctness through the set modifier so I'd go with:

count({$<[Group ID]={"=aggr(count([Client ID]),[Group ID])=1"}>} [Group ID])

akmughal
Contributor II
Contributor II
Author

Hi-

It gives me the count of all entries but I'm looking for the unique count of client group id who has just one entry date.

Thanks,

Asif

albertovarela
Partner - Specialist
Partner - Specialist

Strange. Here's what I got using your sample data... 

 

2021-08-10_11-00-43.png

 

akmughal
Contributor II
Contributor II
Author

I apologize.. I meant to reply on other post.

 

It should give result 3 because client 2,3,8 and 11 entered once but have 3 unique group id.

 

Thank you,

Asif

albertovarela
Partner - Specialist
Partner - Specialist

Use this then: count(Distinct {$<[Client ID]={"=aggr(count([Entry Date]),[Client ID])=1"}>} [Group ID])

akmughal
Contributor II
Contributor II
Author

Does that give you the result 3?

I'm running the statement on real data and does not get the accurate count.

 

albertovarela
Partner - Specialist
Partner - Specialist

Yes, I got 3.  Attached is the qvf

2021-08-10_11-00-43.png