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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

A count based on a selected field

Hi,

I'm working on a school attendance report, and I sincerely hope you can help:

Days absent (A)PersonID (B)Attendance stat (C)AbsenceType (D)SchoolName (E)
11ValidOxford
12Not validOxford
43ValidCambridge
24No reason given

Essex

-5Not validCambridge
26No reason givenEssex
47Not validCambridge

I need an expression for column (C): How do I divide the total number of days in column A (Days) on the number of students (count(distinct personID)) in the selected school(s) in column E (SchoolName)? It is important that the user can change the selection, for example by selecting just one AbscenceType code and still see the stats in column (C) based on the total count of students in the selected schools in column (E).

1 Solution

Accepted Solutions
vincent_ardiet
Specialist
Specialist

Hi,

You can use aggr to sum at school level and a set analysis to ignore the absence type, try something like this :

 

=aggr(nodistinct sum({<AbsenceType=>}Days),SchoolName)/count(personID)

Regards,

Vincent

View solution in original post

3 Replies
swuehl
MVP
MVP

You probably need to ignore your selections using set analysis, like

= sum([Days absent (A)])  / count({1} DISTINCT [PersonID (B)])

vincent_ardiet
Specialist
Specialist

Hi,

You can use aggr to sum at school level and a set analysis to ignore the absence type, try something like this :

 

=aggr(nodistinct sum({<AbsenceType=>}Days),SchoolName)/count(personID)

Regards,

Vincent

Not applicable
Author

That did it, thanks!