Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
keMCW
Contributor
Contributor

How can I reduce multiple rows into one under each unique ID by most recent update?

I'm new to Qlik, so this could very well be an easy fix that I haven't learned yet. I am trying to create a sheet with various patient information to perform audits, including: [PATID], [Level Assignment Date], [Clinician Assignment Date], [Current Level], [Attending Clinician] (this is the sort order). I want to reduce all rows into 1 for each patient ID ([PATID]) by their most recent updates. I was able to pare down level assignments by date using: 

=aggr(max([Current Level]), PATID) 

=aggr(max([Level Assignment Date]), PATID)

under current level & level assignment date dimensions, respectively. I'm having issues w/ the clinician dimensions as names won't sort under max, and in few instances multiple entries were made on the most recent assignment date. FirstSortedValue only brought up errors. Here is an example of what I started with:

PATID Current Level Level Assignment Date Attending Clinician Clinician Assignment Date
123 1 1/1/2022 Doe 1/1/2022
123 1 1/1/2022 Jones 3/1/2022
123 1 1/1/2022 Smith 3/1/2022
456 1 1/1/2022 Doe 1/1/2022
456 2 2/1/2022 Smith 1/1/2022
789 1 1/1/2022 Doe 1/1/2022
789 3 2/1/2022 Jones 2/1/2022
789 3 3/1/2022 Smith 3/1/2022
789 2 4/1/2022 Doe 4/1/2022
1011 1 1/1/2022 Smith

1/1/2022

 

What I was able to pare down by level date:

PATID Current Level Level Assignment Date Attending Clinician Clinician Assignment Date
123 1 1/1/2022 Doe 1/1/2022
123 1 1/1/2022 Jones 3/1/2022
123 1 1/1/2022 Smith 3/1/2022
456 2 2/1/2022 Doe 1/1/2022
456 2 2/1/2022 Smith 1/1/2022
789 2 4/1/2022 Doe 1/1/2022
789 2 4/1/2022 Jones 2/1/2022
789 2 4/1/2022 Smith 3/1/2022
789 2 4/1/2022 Doe 4/1/2022
1011 1 1/1/2022 Smith 1/1/2022

 

What I want:

PATID Current Level Level Assignment Date Attending Clinician Clinician Assignment Date
123 1 1/1/2022 Smith 3/1/2022
456 2 2/1/2022 Smith 1/1/2022
789 2 4/1/2022 Doe 4/1/2022
1011 1 1/1/2022 Smith 1/1/2022

 

Is this possible? I do not have access to the script. Any and all help is appreciated!

*(these values are fake & contain no patient information)

Labels (3)
2 Replies
G3S
Creator III
Creator III

have you tried the max with the 'Clinician Assignment Date' field? like the other ones you mentioned?

aggr(max([Clinician Assignment Date]), PATID)

 

keMCW
Contributor
Contributor
Author

Sorry, should have specified in the original post. I have tried the nested aggr w/ max [Clinician Assignment Date], but it still brought up multiple rows under each [PATID]