Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
girish_talele
Creator
Creator

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.

6 Replies
Not applicable

Hi Girish;

you just needed to organize the table

order by Order,Qty1, Qty2 asc;

best regards.

girish_talele
Creator
Creator
Author

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

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
Creator
Creator
Author

Thanks again Claudio,

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

Regards,

Girish.

Not applicable

Hi Girish

see if this way meets your needs.

girish_talele
Creator
Creator
Author

Dear Claudio,

Thanks again,

But the results are not getting achieved.

Is there any other way???

Regards,

Girish.