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

The internal logic values are in the script

Hello, look at the following table. How to automatically generate the START DATE and END DATE fields in the script?

The start and end dates are taken from RUN_DATE as the contract number and audit result change.

Contract NO.Run_DateAudit ResultSTART DATEEND DATE
37000000595982020/11/21Normal  
37000000595982020/11/22Normal  
37000000595982020/11/22Normal2020/11/212020/11/22
37000000595982020/11/23Update Location  
37000000595982020/11/24Update Location2020/11/232020/11/24
37000000595982020/11/25Normal  
37000000595982020/11/26Normal2020/11/252020/11/26
37000000555552020/11/21Normal  
37000000555552020/11/22Normal2020/11/212020/11/22
1 Solution

Accepted Solutions
Taoufiq_Zarra

@wood  May be this :

Data:

LOAD *,if(rowno()=1,1,if(peek([Contract NO.])=[Contract NO.] and [Audit Result]=peek([Audit Result]),peek(Idtmp),peek(Idtmp)+1)) as Idtmp INLINE [
    Contract NO., Run_Date, Audit Result
    3700000059598, 2020/11/21, Normal
    3700000059598, 2020/11/22, Normal
    3700000059598, 2020/11/22, Normal
    3700000059598, 2020/11/23, Update Location
    3700000059598, 2020/11/24, Update Location
    3700000059598, 2020/11/25, Normal
    3700000059598, 2020/11/26, Normal
    3700000055555, 2020/11/21, Normal
    3700000055555, 2020/11/22, Normal
];

output:
noconcatenate

load * resident Data;
left join load [Contract NO.],[Audit Result],Idtmp,Date(Min(Date#(Run_Date,'YYYY/MM/DD'))) as [START DATE],Date(Max(Date#(Run_Date,'YYYY/MM/DD'))) as [END DATE] resident Data group by [Contract NO.],[Audit Result],Idtmp;

drop table Data;
drop fields Idtmp;

 

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") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

@wood  May be this :

Data:

LOAD *,if(rowno()=1,1,if(peek([Contract NO.])=[Contract NO.] and [Audit Result]=peek([Audit Result]),peek(Idtmp),peek(Idtmp)+1)) as Idtmp INLINE [
    Contract NO., Run_Date, Audit Result
    3700000059598, 2020/11/21, Normal
    3700000059598, 2020/11/22, Normal
    3700000059598, 2020/11/22, Normal
    3700000059598, 2020/11/23, Update Location
    3700000059598, 2020/11/24, Update Location
    3700000059598, 2020/11/25, Normal
    3700000059598, 2020/11/26, Normal
    3700000055555, 2020/11/21, Normal
    3700000055555, 2020/11/22, Normal
];

output:
noconcatenate

load * resident Data;
left join load [Contract NO.],[Audit Result],Idtmp,Date(Min(Date#(Run_Date,'YYYY/MM/DD'))) as [START DATE],Date(Max(Date#(Run_Date,'YYYY/MM/DD'))) as [END DATE] resident Data group by [Contract NO.],[Audit Result],Idtmp;

drop table Data;
drop fields Idtmp;

 

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") 😉
wood
Contributor III
Contributor III
Author

thank you Zarra