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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Siraj
Contributor
Contributor

Compare with previous row date and identify min or max

Hi, 

I have below scenario. please provide the solution.

Need to identify the project number which phase date is greater than previous phase date.

In the below example third phase date is less than second phase, So my condition result would be pick the project number  A-1234.

Project NumberPhasePhase Date (MM/DD/YYYY)
A-1234First Phase04/18/2019
A-1234 Second Phase05/25/2019
A-1234 Third Phase02/21/2019
A-1234 Fourth Phase08/22/2019
B-5678 First Phase01/25/2019
B-5678 Second Phase02/22/2019
B-5678 Third Phase03/28/2019
B-5678 Fourth Phase05/30/2019

 

Thanks in Advance.

Sirajahamed S

3 Solutions

Accepted Solutions
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

if you could solve that inside the script, try with something like this (before of that, you have to order your data):

If([Project Number]=Previous([Project Number]), If([Phase Date (MM/DD/YYYY)]<Previous([Phase Date (MM/DD/YYYY)]),[Project Number]))

View solution in original post

sunny_talwar

Try this

TempLogicalSequence:
LOAD ProjectNumber,
     Proj_Del_Order as Phase_ORDER,
     If(ProjectNumber = Previous(ProjectNumber),
          If(DelDue < Previous(DelDue), 1, 0)
     ) as Due_Date_Sequence
Resident HighlightProjectDel
Order By ProjectNumber, Phase_ORDER, DelDue;

View solution in original post

StarinieriG
Partner - Specialist
Partner - Specialist

You have not to order by date to use that expression. Only by ProjectNumber

View solution in original post

6 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

if you could solve that inside the script, try with something like this (before of that, you have to order your data):

If([Project Number]=Previous([Project Number]), If([Phase Date (MM/DD/YYYY)]<Previous([Phase Date (MM/DD/YYYY)]),[Project Number]))

Siraj
Contributor
Contributor
Author

Hi

Thanks for your reply. I will try this and let you know.
Siraj
Contributor
Contributor
Author

Hi,

I am not getting the result. Below is my script


TempLogicalSequence:
load
ProjectNumber,
Proj_Del_Order as Phase_ORDER,
if(ProjectNumber=previous(ProjectNumber),
if(date(DelDue,'MM/DD/YYYY')<previous(date(DelDue,'MM/DD/YYYY')),1,0)) as Due_Date_Sequence
resident HighlightProjectDel

order by Phase_ORDER asc, DelDue asc;

 

Could you provide any solution

Thanks in advance

Sirajahamed S

 

sunny_talwar

Try this

TempLogicalSequence:
LOAD ProjectNumber,
     Proj_Del_Order as Phase_ORDER,
     If(ProjectNumber = Previous(ProjectNumber),
          If(DelDue < Previous(DelDue), 1, 0)
     ) as Due_Date_Sequence
Resident HighlightProjectDel
Order By ProjectNumber, Phase_ORDER, DelDue;
StarinieriG
Partner - Specialist
Partner - Specialist

You have not to order by date to use that expression. Only by ProjectNumber

Siraj
Contributor
Contributor
Author

Hi 

Thanks to both. It was working fine  by removing the date in order by .