Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Simon4
Creator
Creator

only max date

Hi all,

I have this table:

Simon4_0-1675197310983.png

I only want to show the max startdate, in this case 11/3/2022 and the corresponding timetable_id. how do i achieve this? f.y.i. I have multiple employee_code

 

Labels (2)
2 Solutions

Accepted Solutions
KGalloway
Creator II
Creator II

For clarification, you want a table like this:

Employee_code, max(STARTDATE), timetable_id (of the max start date)

9147, 11/3/2022, 25

1234, 6/7/2022, 4

 

Is that correct?

If so, then a table with the following data should work:

Dimensions: employee_code

Measures: max(startdate) and firstsortedvalue(timetable_id, -startdate)

 

KGalloway_0-1675202149601.png

 

 

View solution in original post

Simon4
Creator
Creator
Author

Hello Galloway,

You where right after all. But I also needed distinct.

Simon4_0-1675437457117.png

firstsortedvalue( timetable_id, -aggr(max(if(STARTDATE<(vPeildatum)+1,STARTDATE)), Employee_code))

 thanks for helping.

View solution in original post

7 Replies
KGalloway
Creator II
Creator II

For clarification, you want a table like this:

Employee_code, max(STARTDATE), timetable_id (of the max start date)

9147, 11/3/2022, 25

1234, 6/7/2022, 4

 

Is that correct?

If so, then a table with the following data should work:

Dimensions: employee_code

Measures: max(startdate) and firstsortedvalue(timetable_id, -startdate)

 

KGalloway_0-1675202149601.png

 

 

Simon4
Creator
Creator
Author

Hi,

 

Thank you for your response.

 

Yes this is what I want to achieve. I already tried this but it does not work for me.

Simon4_0-1675418364076.png

 

Why would this be?

 

Renatusfreitas
Partner - Contributor III
Partner - Contributor III

Olá @Simon4 , faça um teste trabalhando no script, aqui está uma forma de retornar apenas o último registro de uma lista agrupando pelo Employee_code.

Renatusfreitas_1-1675425475188.png

Desta forma irá retornar uma tabela com a última Startdate e calendar_id para cada Employee_code.

Renatusfreitas_2-1675425631366.png

Faça esse teste, Espero que essa solução contribua.

 

Se está solução ajudou, aceite-a como uma solução.

https://br.linkedin.com/in/renatusfreitas

https://cubotimize.com/
Simon4
Creator
Creator
Author

Hi Renatusfreitas,

 

Thank you for your response.

This indeed works and has been my temporary solution.

Simon4_0-1675426353404.png

but I need the timetable_id to be flexible because I have KPI's set up till 12 months back. now when someone switches timetable_id the KPI's will result faulty data, because the hours connected to the timetable_id changed.

So I imagine it can't be done in the data load editor because then the timetable-id and startdate are fixed.

any other suggestion?

 

 

WildmoserGeorg
Contributor III
Contributor III

Hi,

KGalloway solution works very well. Is it possible that you have the formula put in dimesion instead of expression?

WildmoserGeorg_1-1675433385982.png

 

WildmoserGeorg_0-1675433235209.png

BG

 

WildmoserGeorg
Contributor III
Contributor III

or you have a problem with the format. then try:

firstsortedvalue(Calendar_id, -date(Startdate))

Simon4
Creator
Creator
Author

Hello Galloway,

You where right after all. But I also needed distinct.

Simon4_0-1675437457117.png

firstsortedvalue( timetable_id, -aggr(max(if(STARTDATE<(vPeildatum)+1,STARTDATE)), Employee_code))

 thanks for helping.