Skip to main content
Announcements
New: No-code data prep in Qlik Cloud Analytics™ TAKE A TOUR
cancel
Showing results for 
Search instead for 
Did you mean: 
Ineshsingh
Contributor
Contributor

Getting top 5 entries based on end date

I need to show top 3 items based on their end dates

ID Service End Date
33855 XYZ 1-Jun-23
5400 YZB 27-Aug-23
28004 XSD 31-May-23
26146 ASA 12-Jul-23
14358 LKI 30-Jun-23
26054 BKJN 3-Jan-24
32883 YFK 12-Aug-25

 

It should display:

ID Service End Date
28004 XSD 31-May-23
33855 XYZ 1-Jun-23
14358 LKI 30-Jun-23

 

and Additional if I can display text saying  - "Service XSD going to expire on 31st May 2023"

Labels (4)
1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

Hi @Ineshsingh , i made this example, hopes works for you :

 

//Script  to format the field as date :

Aux:
Load * INLINE [
ID, Service, EndDate
33855, XYZ, 1-Jun-23
5400, YZB, 27-Aug-23
28004, XSD, 31-May-23
26146, ASA, 12-Jul-23
14358, LKI, 30-Jun-23
26054, BKJN, 3-Jan-24
32883, YFK, 12-Aug-25
];

 

Aux:
Load
ID,
Service,
date#(EndDate, 'dd-MMM-YY') as EndDate2
Resident Aux
order by
EndDate;

drop table Aux;

exit script;

//Then in a straight table :

QFabian_0-1673011472232.png

QFabian_1-1673011496163.png

QFabian_2-1673011551718.png

QFabian_3-1673011580362.png

 

 

QFabian

View solution in original post

2 Replies
QFabian
Specialist III
Specialist III

Hi @Ineshsingh , i made this example, hopes works for you :

 

//Script  to format the field as date :

Aux:
Load * INLINE [
ID, Service, EndDate
33855, XYZ, 1-Jun-23
5400, YZB, 27-Aug-23
28004, XSD, 31-May-23
26146, ASA, 12-Jul-23
14358, LKI, 30-Jun-23
26054, BKJN, 3-Jan-24
32883, YFK, 12-Aug-25
];

 

Aux:
Load
ID,
Service,
date#(EndDate, 'dd-MMM-YY') as EndDate2
Resident Aux
order by
EndDate;

drop table Aux;

exit script;

//Then in a straight table :

QFabian_0-1673011472232.png

QFabian_1-1673011496163.png

QFabian_2-1673011551718.png

QFabian_3-1673011580362.png

 

 

QFabian
QFabian
Specialist III
Specialist III

@Ineshsingh Excelent!, here is included the comment :

Aux:
Load * INLINE [
ID, Service, EndDate
33855, XYZ, 1-Jun-23
5400, YZB, 27-Aug-23
28004, XSD, 31-May-23
26146, ASA, 12-Jul-23
14358, LKI, 30-Jun-23
26054, BKJN, 3-Jan-24
32883, YFK, 12-Aug-25
];

 

Aux:
Load
ID,
Service,
date#(EndDate, 'dd-MMM-YY') as EndDate2,
'Service ' & Service & ' going to expire on ' & date#(EndDate, 'dddd-MMM-YYYY') as Comment
Resident Aux
order by
EndDate;

drop table Aux;

exit script;

QFabian