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: 
Not applicable

How to use Max function int this case

Hi,

I have three fields- ID, Date and code each ID has multiple date and respective multiple codes. The way i am trying to do this is i need to create a filter which just says (1,0) where if it's "1" then there is ID with a most recent date and respective code, if "0" default it to the way it is where ID has multiple dates and respective codes.

I have tried to create a different table and concatenate or join back to the actual table no nothing worked for me, hope that some one can help me with this?

IDDateCode
128941/22/2013acedr
128941/23/2013teyhcu
128941/24/2013sheyc
128941/25/2013uieldo
190282/16/2013odleif
190282/17/2013iepdls
190282/18/2013qpalif
190282/19/2013oslpar
1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

Table1:

LOAD ID, Date, Code FROM ...;

LEFT JOIN LOAD

     ID,

     max(Date) as Date,

     1 as MaxDate

RESIDENT Table1

GROUP BY ID;

Your Date should be recognized as Date by QV, having a numeric representation. Set your DateFormat variable accordingly, if needed.

edit: Selecting 1 from field MaxDate should limit your records to the latest codes then, not selecting anything in field MaxDate should show all records.

View solution in original post

3 Replies
swuehl
MVP
MVP

Maybe like

Table1:

LOAD ID, Date, Code FROM ...;

LEFT JOIN LOAD

     ID,

     max(Date) as Date,

     1 as MaxDate

RESIDENT Table1

GROUP BY ID;

Your Date should be recognized as Date by QV, having a numeric representation. Set your DateFormat variable accordingly, if needed.

edit: Selecting 1 from field MaxDate should limit your records to the latest codes then, not selecting anything in field MaxDate should show all records.

Not applicable
Author

This definetly makes sense Swuehl, I think this should give me the desired result but right now i am still doing some testing on this. But thanks for the quick response.

Not applicable
Author

Exact result that i needed.