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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Lobby
Contributor II
Contributor II

Selecting a value in a column in the same row as the max date in another column

Hi All,

Thank you in advance for any support you can give! I have a data model with two tables, clients, projects, and reviews. Each client can have multiple projects, and each project can have multiple reviews. Within the review table, there are two dates: the planned date for the review and the actual date of the review. I am trying to create a straight table that shows client_id, project_id, the planned date of their latest review, and the actual date of their latest review. It is important to note that it is possible for the planned date field to be filled but the actual date to be null if the review hasn't actually happened yet. See below as an example.

Client_idProject_idplanned_dateactual_date
1A12/12/2024-
1A11/10/202402/01/2025
1B14/12/202403/01/2025
2C15/12/2024-
2C16/12/202405/01/2025
3D17/12/202406/01/2025

 

When I make this table, I have the client_id and the project_id as dimensions in the table. I added the latest planned review date as a measure so I could use Max() to find the latest review. I would then like to populate the actual date column with the cell associated with that latest planned date. If the review hasn't happened yet, I want the actual date to return a null value as is in the data model.

I am unsure how to achieve this. I cannot use Max() again as if the review hasn't happened yet, this is null. I couldn't use Aggr either as, if I understand correctly, it provides an aggregation based on dimensions not a dimension based on the return of an aggregation. I am also trying set analysis but can't quite get it to work. Any help would be greatly appreciated!

Labels (4)
4 Replies
Chanty4u
MVP
MVP

Try this 

Max(

  {<

    planned_date = {"=$(=Max(planned_date))"}

  >}

  actual_date

)

Chanty4u
MVP
MVP

Or may be 

Only(

  {<

    planned_date = {"=$(=Max(planned_date))"}

  >}

  actual_date

)

marcus_sommer

I'm not quite sure if I understand your use-case right but I would tend to do the essential work within the data-model and not with UI measures.

This could be mean to apply n aggregation like:

m: mapping load Client_id & '|' & Project_id, max(planned_date)
from X group by Client_id & '|' & Project_id; // optional where ...

and then using n applymap() to fetch the wanted data again.

Further helpful could be to use interrecord-functions like peek() and previous() within appropriate sorted resident-loads to create a running counter-information per key-value and/or offset-values between the dates and/or various other flag-information.

Or
MVP
MVP

This looks like a use case for FirstSortedValue(), which you can apply in a measure, once for each date field.