Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
Following problem:
Have a list of deliveries & Ids.
And there is a flag (special treatment) for one Id/Delivery (marked with x)
I would now like to copy this flag on all following Id's of the deliverys.
Delivery | Id | Flag_temp | Flag |
123 | 1 | x | x |
123 | 2 | 0 | x |
123 | 3 | 0 | x |
345 | 1 | 0 | 0 |
345 | 2 | x | x |
345 | 3 | 0 | x |
345 | 4 | 0 | x |
367 | 1 | 0 | 0 |
367 | 2 | 0 | 0 |
367 | 3 | x | x |
367 | 4 | 0 | x |
367 | 5 | 0 | x |
Tried this, bit didn't work:
temp:
load * inline
[Delivery, Id, Flag_temp
123, 1, x
123, 2, 0
123, 3, 0
345, 1, 0
345, 2, x
345, 3, 0
345, 4, 0
367, 1, 0
367, 2, 0
367, 3, x
367, 4, 0
367, 5, 0];
Flag:
NoConcatenate load *,
if(Flag_temp = 'x', 'x', if(Delivery = Previous(Delivery) and Previous('Flag') = 'x','x',0)) as Flag
Resident temp order by Delivery, Id asc;
drop table temp;
Thank you!
Try this script:
load
*,
IF( Flag_temp = 'x',
Flag_temp,
if( peek(Delivery) = Delivery,
peek(Flag),
Flag_temp)
) as Flag
inline [
Delivery, Id, Flag_temp
123, 1, x
123, 2, 0
123, 3, 0
345, 1, 0
345, 2, x
345, 3, 0
345, 4, 0
367, 1, 0
367, 2, 0
367, 3, x
367, 4, 0
367, 5, 0];