Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

create a flag using loop and peek

Hi all,

I'm trying to create a new flag by looking at the previous record it has.

Can someon please help?

Any help is highly appreciated.

Please see the attachemnt

   

TimeFlagReq. output
1nullnull
2yy
3nully
4nully
5nully
6NN
7nullN
1 Solution

Accepted Solutions
sunny_talwar

May be this

Table_Temp:

LOAD * Inline

[

Time, Flag, Req. output

1, null, null

2, y, y

3, null, y

4, null, y

5, null, y

6, N, N

7, null, N

];

Table_Final:

LOAD *,

If(Len(Trim(Previous(Flag))) > 0 and Flag = 'null', Peek('Req Flag'), Flag) as [Req Flag]

Resident Table_Temp

Order By Time;

DROP Table Table_Temp;

View solution in original post

4 Replies
markgraham123
Specialist
Specialist
Author

@Sunny Talwar

Any inputs brother?

sunny_talwar

May be this

Table_Temp:

LOAD * Inline

[

Time, Flag, Req. output

1, null, null

2, y, y

3, null, y

4, null, y

5, null, y

6, N, N

7, null, N

];

Table_Final:

LOAD *,

If(Len(Trim(Previous(Flag))) > 0 and Flag = 'null', Peek('Req Flag'), Flag) as [Req Flag]

Resident Table_Temp

Order By Time;

DROP Table Table_Temp;

markgraham123
Specialist
Specialist
Author

Thank you Brother!!

So, when we say, Flag='Null', then use peek, it keep sskipping till the filed is not 'null' and it finds any other value ??

Please correct if i'm wrong.

sunny_talwar

Yes...