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

Count and Distinct not working

Hi All,

i have been given a dashboard where i found below expressions:

We have a table in the dashboard and its dimension is AY2 variable.

In Expressions, for each expression we define what this AY2 is, for example for Claims Amount:

sum ({<YoA -= {0}>} -(AY2= year(LossAttachmentDate_c)) * [Claim Incurred Net&Tty_c])

Because of that [Claim Incurred Net&Tty_c] is then summarized being grouped by LossAttachmentDate ( = Accident Year). Also if somebody can explain how this expression works, it will be great.

In the table, using different AY2 definitions all works fine, but we have a  problem to count the number of Claims.

To do that, we have to use functions count and distinct but then defining AY2 doesn’t work and it doesn’t count distinctive Claim Numbers well.

count ( DISTINCT {<YoA -= {0}>} -(AY2=year(LossAttachmentDate_c)) * [Claim Number_c])

Do you have any idea what we can do? Or maybe we’re doing something wrong?

 

Regards

Sagar

3 Replies
Anil_Babu_Samineni

It is not comparing correctly, You should use some Aggregate functions like follows

count ( DISTINCT {<YoA -= {0}, AY2={"$(=year(Max(LossAttachmentDate_c)))"}>} [Claim Number_c])

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sagar_vij99
Creator
Creator
Author

Hi Anil,

Thank you so much for reply.

 

Your line of code summaries all claims and displays just the total number for all the years, even when I delete max:

 

 
 

AY           # of Claims

2003       30428

2004       30428

2005       30428

2006       30428

 

30,428 is the total number. And we’re struggling to group it by Accident Year (AY2)  (which is year(LossAttachmentDate_c) for that column.

Maybe it is impossible to define AY2 with count and distinct function?

 

Thanks again for all the help!

Brett_Bleess
Former Employee
Former Employee

Have a look at the following Design Blog post, believe it may be what you need in relation to what Anil was saying:

https://community.qlik.com/t5/Qlik-Design-Blog/Set-Analysis-in-the-Aggr-function/ba-p/1463822

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.