Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator III
Creator III

Max date value in scripting

Hi Community,

I Have to show Max Value records ..

Table:

ContactIDSeqNumberDateSales
10012310004/7/20195000
100123100015/08/20195000
100123100025/09/20192000
100123100125/09/20192500

OutPut:

ContactIDSeqNumberDateSales
100123100025/09/20192000
100123100125/09/20192500

 

MaxValue:
Load * inline [
ContactID, SeqNumber, Date, Sales
100123, 1000, 4/7/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;

I have written firstsortedvalue, but value not coming proper..

What did i wrong here, can you please help me!

Thanks In Advance!

Labels (1)
2 Replies
Taoufiq_Zarra

from what I get that you're taking the Max date as a reference, I'll propose this:

Data:

LOAD RowNo() as IDl,* INLINE [

    ContactID, SeqNumber, Date, Sales
    100123, 1000, 4/7/2019, 5000
    100123, 1000, 15/08/2019, 5000
    100123, 1000, 25/09/2019, 2000
    100123, 1001, 25/09/2019, 2500
];

inner join

load 
FirstSortedValue(IDl, -Date) as IDl

resident Data
group by ContactID,SeqNumber;

output:

 

Capture.JPG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Brett_Bleess
Former Employee
Former Employee

Did Taoufiq's response help you get things working?  If so, do not forget to return to your thread and use the Accept as Solution button to give him credit for the assistance and let other Members know it did work.  We really appreciate it when folks close out their threads, so if you did something different, please consider posting that and then you can use the button to mark that post as the solution too.  If you are still trying to sort things out, please leave an update with what you still need.

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.