Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, could be something like this:
temp_data:
LOAD * INLINE [
VisitID,VisitStatus
70000,Approve
70000,Retest
700001,Approve
700001,Pending
700002,Approve
700002,Pending
700002,Retest
];
temp_data2:
LOAD *,
IF(PREVIOUS(VisitID)=VisitID,PEEK(VisitStatus)) as OldVisitStatus,
IF(PREVIOUS(VisitID)=VisitID,1,0) as req_record_flag,
ROWNO() AS RowId
RESIDENT temp_data;
DROP TABLE temp_data;
temp_data3:
LOAD *,
IF(PREVIOUS(VisitID)=VisitID,0,1) as req_record_flag2
RESIDENT temp_data2
ORDER BY RowId DESC;
DROP TABLE temp_data2;
INNER JOIN (temp_data3)
LOAD
1 AS req_record_flag,
1 AS req_record_flag2
AUTOGENERATE 1;
data:
LOAD
VisitID,
VisitStatus AS NewVisitStatus,
OldVisitStatus
RESIDENT temp_data3;
DROP TABLE temp_data3;
Make sure that the data is loaded in the required order.
Hi @GeorgePhilips23 ,
What is the expected output here?
Please find attached pic for script;
now I need most recent status changes into oldstatus and newstatus;
Thank you!
Hi, could be something like this:
temp_data:
LOAD * INLINE [
VisitID,VisitStatus
70000,Approve
70000,Retest
700001,Approve
700001,Pending
700002,Approve
700002,Pending
700002,Retest
];
temp_data2:
LOAD *,
IF(PREVIOUS(VisitID)=VisitID,PEEK(VisitStatus)) as OldVisitStatus,
IF(PREVIOUS(VisitID)=VisitID,1,0) as req_record_flag,
ROWNO() AS RowId
RESIDENT temp_data;
DROP TABLE temp_data;
temp_data3:
LOAD *,
IF(PREVIOUS(VisitID)=VisitID,0,1) as req_record_flag2
RESIDENT temp_data2
ORDER BY RowId DESC;
DROP TABLE temp_data2;
INNER JOIN (temp_data3)
LOAD
1 AS req_record_flag,
1 AS req_record_flag2
AUTOGENERATE 1;
data:
LOAD
VisitID,
VisitStatus AS NewVisitStatus,
OldVisitStatus
RESIDENT temp_data3;
DROP TABLE temp_data3;
Make sure that the data is loaded in the required order.
Thanks a lot, it worked!
Hi, is there a way to do this from the front end?