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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis and Max(Date)

Hello everybody!

I know there were already some topics on this subject, but I coudn't find any solution for my problem.

I have some historical data under the following form (31/12/999 beign the representation of no end date, current value)

Agency01/01/2012

NameDepartmentStart DateEnd Date
JérômeAgency01/08/200001/01/2012
JérômeTeam GF01/01/201231/12/9999
JérômeTeam GF201/02/201305/11/2013
JérômeTeam GF306/11/201331/12/9999

In an ideal world I shouldn't have 2 values with end date = '31/12/9999' but it's the way the provider works in some incorrect cases.

I want to be able to identify to which department Jérôme belongs at a certain date, input in a Calendar object, in a variable called vRefDate.

I have created the following expression but in that case it returns the both values

count({ $  <[EndDate]={">=$(=timestamp(vRefDate))"},[Start Date]={"<=$(=timestamp(vRefDate))"}> } [Name])

NameDepartmentStart DateEnd Datecount
JérômeTeam GF01/01/201231/12/99991
JérômeTeam GF306/11/201331/12/99991

How can I have only the last line??? I couldn't find a way to use a max date or a first sorted value, but I probably did something wrong 😞

Anybody can help? Thanks in advance!

Ce message a été modifié par : Anne-Lise Freson Add an attachment of a simplified application to show the problem...

16 Replies
Not applicable
Author

Still some problems, it shows nothing, and the editor still notes the <= in red, I think it get lot with the quotes

Not applicable
Author

try this, it is working as you expected

=count({ $  <[Date fin Service]={">=$(=timestamp(vRefDate))"},

[Date début Service]=

  {"$(=

  Date(MAX({<[Date début Service]= {'<=$(=timestamp(vRefDate))'}>}[Date début Service]),'DD/MM/YYYY')

  )"}

  > } [ID Individu])

Not applicable
Author

did the solution work ?

Not applicable
Author

Sorry I was in a meeting this morning, so I could only test it now... and it works great 🙂

thank you very much for your help, and now I know how to manage imbrication with double quote and signle quote...

Not applicable
Author

Finally I was a little too optimistic It works perfectly in the sample application I gave you, but if I have other persons, with different dates, it fails as it takes the max(date) whatever the person. However I need the max(date) from each person...

So if I add cyril in my data...

NameDepartmentStart DateEnd Date
JérômeAgency01/08/200001/01/2012
JérômeTeam GF01/01/201231/12/9999
JérômeTeam GF201/02/201305/11/2013
JérômeTeam GF306/11/201331/12/9999
CyrilIT29/11/201331/12/9999


... I need to have

NameDepartmentStart DateEnd Datecount
JérômeTeam GF306/11/201331/12/99991
CyrilIT29/11/201331/12/99991

If I'm using the proposed expression, I only got

NameDepartmentStart DateEnd Datecount
CyrilIT29/11/201331/12/99991
Not applicable
Author

try this ... if this doesn't work. please provide more data in ur sample app

=

count({ $  <[Date fin Service]={">=$(=timestamp(vRefDate))"},

[Date début Service]=

  {"$(=

  Aggr(Date(MAX({<[Date début Service]= {'<=$(=timestamp(vRefDate))'}>}[Date début Service]),'DD/MM/YYYY'),[Nom & Prénom])

  )"}

  > } [ID Individu])

Not applicable
Author

Does not work... Here is a new version of the application with 2 more people so you can see (I put back again my intial expression so you can see the value)