Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

girish_talele
Contributor

Peek previous row value if condition is true

Hi,

I have a sample data as given in below image (column A to D),

As a result I want Qty2 of previous row (Column E) of same order and where the Key not equals to "Key5".

Untitled.jpg

Using Peek() function, I am able to get required results, Results are coming as shown below,

IF(peek(Order,-1)=Order and Key<>'Key5',peek(Qty2,-1),Qty1)as Previous_QTy2

Untitled.jpg

Please suggest is there any way to achieve said results.

Regards,

Girish.

Tags (3)
6 Replies
Not applicable

Re: Peek previous row value if condition is true

Hi Girish;

you just needed to organize the table

order by Order,Qty1, Qty2 asc;

best regards.

girish_talele
Contributor

Re: Peek previous row value if condition is true

Dear Claudio,

Thanks for looking into, I have checked the statement of "order by" but it is given the results as shown below,

Untitled.jpg

The requirement is such that the sequence of data is important, so that order by will not work in our case.

Any other solution?

Not applicable

Re: Peek previous row value if condition is true

Hi Girish,

peek function requires that the table is sorted, you can ordering it again after creating the field previous_QTy2 using another standard to create the field Rowno.

girish_talele
Contributor

Re: Re: Peek previous row value if condition is true

Thanks again Claudio,

But I am failed to simulate your solution, can you please help me by checking & correcting the attached qvw.

Regards,

Girish.

This widget could not be displayed.
This widget could not be displayed.