Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator II
Creator II

Max Date Value - Scripting Side

Hi Community,

I'm facing issue with Max date value  - we need fetch which has the maximum date value

ContactIDSeqNumberDateSales
100123100004/07/20195000
100123100015/08/20195000
100123100025/09/20192000
100123100125/09/20192500

OutPut:

ContactIDSeqNumberDateSales
100123100025/09/20192000
100123100125/09/20192500

 

Have used FirstSortedValue, but it's not working..

MaxValue:
Load * inline [
ContactID, SeqNumber, Date, Sales
100123, 1000, 04/07/2019, 5000
100123, 1000, 15/08/2019, 5000
100123, 1000, 25/09/2019, 2000
100123, 1001, 25/09/2019, 2500
];

JOIN
Load
         ContactID,
         SeqNumber,
         Date(Max(Date)) as Date,
         FirstSortedValue(Sales, -Date) as MaxValue
Resident MaxValue
Group By  ContactID,
                     SeqNumber;

Can you please help me!....

 

Thanks In Advance!!

Labels (1)
3 Replies
tresesco
MVP
MVP

If you need just two rows as output, you don't need JOIN here. And one more thing you have to ensure that qlik is reading your date values as dates not string; for that set your system variable properly.

SET DateFormat='D/M/YYYY';

MaxValue:
Load * inline [
ContactID, SeqNumber, Date, Sales
100123, 1000, 04/07/2019, 5000
100123, 1000, 15/08/2019, 5000
100123, 1000, 25/09/2019, 2000
100123, 1001, 25/09/2019, 2500
];

/**** No JOIN***/

Final:
Load
         ContactID,
         SeqNumber,
         Date(Max(Date)) as Date,
         FirstSortedValue(Sales, -Date) as MaxValue
Resident MaxValue
Group By  ContactID,
                     SeqNumber;

Drop table MaxValue;

Kushal_Chawda

may be this

Data:
LOAD
    ContactID,
    SeqNumber,
    "Date",
    Sales
FROM [lib://Qlik]
(html, utf8, embedded labels, table is @1);

inner Join(Data)
Load ContactID,
    SeqNumber,
    Date(max(Date)) as Date
Resident Data
Group by ContactID,
    SeqNumber;
Brett_Bleess
Former Employee
Former Employee

Paul, did either of the posts get you what you needed for your use case?  If so, please do not forget to return to your thead and on the post that helped you, use the Accept as Solution button to mark that as the solution, which gives credit to the poster and lets other Members now what actually worked.  We appreciate it if you can close out the thread.  If you are still needing help, leave an update on where you stand with things.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.