Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Peek/order by problem

Hi

I am struggling to udnerstand why the peek function is not working correctly for me.

I am using the following code to ascertain if two consecutive rows have a flag, and if so populate a row:

Load *,
if(EmailFlag = '1', if(peek(PlanFlag) = EmailFlag and peek(OpCode) = OpCode and peek(account) = account,'Email Sent','Email Not Sent'),'') as EmailSentFlag

Resident DebttransMO

Order by account,OpCode, date,time desc;

The strange thing is that for some records it works fine - however for others it does not. As you can see from the below, there are 3 occasions where both flags are populated but only one shows Email Sent in the EmailSentFlag column despite the same conditions being met.

SShot.png

Can anyone help exaplin this?

Thanks!

4 Replies
Not applicable

Re: Peek/order by problem

No this makes no sense to me

Not applicable

Re: Peek/order by problem

Thanks for that.

MVP
MVP

Re: Peek/order by problem

Please check that the table in the front end you are looking at is sorted in the exact order and direction as in the load script (e.g. by adding a Recno() as RecID in the load and sort by this field in your front end).

I noticed that your date and time fields are showing same values for the records (per case), could that be a problem?

Not applicable

Re: Peek/order by problem

Thanks for the response.

I've used the recno() function and it seems although some sections of the data are ordered correctly others aren't.

My fact table comprises of 3 concatenations - do I need to order each of these individually or just at the final resident load?

Community Browser