Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

laurischarf
Contributor II

Get value for record with most recent date

I have an app with one table with blood pressure readings for many patients. FIelds are PatientID, ObservationValue, ObservationDate, and RowID (created using RowNo()).

I want to show a table with every PatientID and his/her most recent ObservationValue (based on ObservationDate).

PatientID is a dimension in the table.

I've tried various ways to get the ObservationValue, to no avail:

=max({$<ObservationDate={"$(=max(aggr(max(ObservationDate), PatientID))"} >} ObservationValue)

=max({$<ObservationDate={"$(=aggr(max(ObservationDate), PatientID)"} >} ObservationValue)

and as a dimension:

=Aggr(max({$<ObservationDate={"$(=aggr(max(ObservationDate), PatientID)"} >} ObservationValue), PatientID)

The above all return null.

This returns each patient's max(ObservationValue) and ignores the ObservationDate, so it's wrong:

=max({$<ObservationDate={"=$(=max(ObservationDate))"} >} num(ObservationValue))

I must be over-complicating this...

1 Solution

Accepted Solutions
MVP
MVP

Re: Get value for record with most recent date

With PatientID as a dimension, you can use

=FirstSortedValue(ObservationValue, -ObservationDate)


to find the most recent observation value

2 Replies
MVP
MVP

Re: Get value for record with most recent date

With PatientID as a dimension, you can use

=FirstSortedValue(ObservationValue, -ObservationDate)


to find the most recent observation value

laurischarf
Contributor II

Re: Get value for record with most recent date

Yes! Thanks so much, Jonathan. I figured there had to be a simpler solution!

Community Browser