Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Keyuser
Contributor
Contributor

Peek Flag

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. 

DeliveryIdFlag_tempFlag
1231xx
12320x
12330x
345100
3452xx
34530x
34540x
367100
367200
3673xx
36740x
36750x

 

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!

 

1 Reply
Vegar
MVP
MVP

Try this script:

image.png

 

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];