Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am brand new to Qlik and having a hard time writing an expression for a KPI. None of the other similar questions on the forum have resolved my problem.
I would like to return average of AGE, grouped by DISTINCT PATIENTID — that is, RecordNum 4 should not be included in the Avg calculation.
RecordNum | PatientID | Age | DateOfVisit |
1 | 1234 | 15 | 1/24/2021 |
2 | 2345 | 66 | 1/25/2021 |
3 | 3456 | 45 | 2/10/2021 |
4 | 1234 | 15 | 2/19/2021 |
The expected result is 42: (15 + 66 + 45)/3
I'll forgo cluttering this question with my various attempts, but any help is appreciated.
Sum(Aggr(Age, PatientID))/count(distinct PatientID)
but what if the age changes? say for patient 1234, on 2/19/2021 this person becomes 16 years old? in case you want the avg, use Sum(Aggr(avg(Age), PatientID))/count(distinct PatientID)