Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

markgraham123
Valued Contributor

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

Re: create a flag using loop and peek

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;

4 Replies
markgraham123
Valued Contributor

Re: create a flag using loop and peek

@Sunny Talwar

Any inputs brother?

Re: create a flag using loop and peek

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
Valued Contributor

Re: create a flag using loop and peek

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.

Re: create a flag using loop and peek

Yes...

Community Browser