Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
spetushi
Creator
Creator

Rank dates within a record

Hello,

I am loading a table in qlikview similar to this sample:

IDSeqNrDate
11105-Sep-2015
12807-Oct-2015
11426-Sep-2015
21813-Sep-2015
22115-Sep-2015
22225-Sep-2015
22705-Oct-2015
33215-Oct-2015
49221-Nov-2015
49525-Nov-2015

Would like to rank the dates within each ID from oldest to earliest. Tried different concepts using grouping and while loop, but couldn't get it to work. Desired result:

IDSeqNrDateRank
11105-Sep-20151
12807-Oct-20153
11426-Sep-20152
21813-Sep-20151
22115-Sep-20152
22225-Sep-20153
22705-Oct-20154
33215-Oct-20151
49221-Nov-20151
49525-Nov-20152

Thank you

14 Replies
Saravanan_Desingh

Hi Sunny,

I'm getting exactly what you are getting.

In your first picture: Shouldn't the Rank be : 1,3,2? (5/Sep,7/Oct,26/Sep)

sunny_talwar

I see what you mean

sunny_talwar

The issue was that the date wasn't read by QlikView.

Check now:

Data:

LOAD ID,

  SeqNr,

  Date#(Date, 'DD-MMM-YYYY') as Date;

LOAD * INLINE [

    ID, SeqNr, Date

    1, 11, 05-Sep-2015

    1, 28, 07-Oct-2015

    1, 14, 26-Sep-2015

    2, 18, 13-Sep-2015

    2, 21, 15-Sep-2015

    2, 22, 25-Sep-2015

    2, 27, 05-Oct-2015

    3, 32, 15-Oct-2015

    4, 92, 21-Nov-2015

    4, 95, 25-Nov-2015

];

DataOut:

LOAD ID,

        SeqNr,

        Date,

        Autonumber(Date, ID) as Rank

RESIDENT Data

ORDER BY ID, Date asc;

DROP TABLE Data;

Capture.PNG


Saravanan_Desingh

Thank you sunindia. Perfected now..

Valerie
Contributor III
Contributor III

Thank, autonumber function works but it takes quiet long to run the script, probably because of the size of my data. Any alternative?