Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

ashokvelisetty
New Contributor II

App is running 10 hrs due to Loops and Peek????

Hi All,

I am using Loops and Peek functions to get the Last team data in Ticket history table.Logic is working fine but it runs too slow and takes 10+ hrs to complete the load.

   

Requirement is needs to pick most recent team details only per each ticket.

For more details please open attached excel where you can find sample Input and Output format.

Code i written in my application is below.

Ticket_History:

Load

    TCKT_HIS_KEY_AS_NUM,

    Ticket_His_TeamName,

    START_DATE_TIME,

    END_DATE_TIME,

    Ticket_His_OpenStatus_Desc

  

Resident    Ticket_History1

Order by TCKT_HIS_KEY_AS_NUM,START_DATE_TIME desc , END_DATE_TIME desc;

Let vNoOfRows = NoOfRows('Ticket_History');

set vFlag=1;

FOR i=0 to $(vNoOfRows)-1

  Let i1= $(i)+1;

  Let vTicketKey2=Peek('TCKT_HIS_KEY_AS_NUM',$(i),'Ticket_History');

  Let vTicketKey3=Peek('TCKT_HIS_KEY_AS_NUM',$(i1),'Ticket_History');

  SET vTicketKey=Peek('TCKT_HIS_KEY_AS_NUM',$(i),'Ticket_History');

  SET vTicketKey1=Peek('TCKT_HIS_KEY_AS_NUM',$(i1),'Ticket_History');

  SET vTeam=Peek('Ticket_His_TeamName',$(i),'Ticket_History');

  SET vST=Peek('START_DATE_TIME',$(i),'Ticket_History');

  SET vET=Peek('END_DATE_TIME',$(i),'Ticket_History');

  SET vStatus=Peek('Ticket_His_OpenStatus_Desc',$(i),'Ticket_History');

  SET vKey=Peek('TCKT_HIS_KEY_AS_NUM',$(i),'Ticket_History')& Peek('Ticket_His_TeamName',$(i),'Ticket_History');

  SET vKey1=Peek('TCKT_HIS_KEY_AS_NUM',$(i1),'Ticket_History')& Peek('Ticket_His_TeamName',$(i1),'Ticket_History');

  Let vKey2=AutoNumber(Peek('TCKT_HIS_KEY_AS_NUM',$(i),'Ticket_History')& Peek('Ticket_His_TeamName',$(i),'Ticket_History'));

  lET vKey3=AutoNumber(Peek('TCKT_HIS_KEY_AS_NUM',$(i1),'Ticket_History')& Peek('Ticket_His_TeamName',$(i1),'Ticket_History'));

TestReplicate:

LOAD  $(vTicketKey) as Ticket,

      $(vTeam) as Team,

      $(vST) as ST,

      $(vET) as ET,

      $(vStatus) as Status,

      $(vKey) AS Key,

      $(vKey1) AS Key1,

      $(vFlag) as Flag

  AutoGenerate(1);

//  TRACE $(vKey2) = $(vKey3);

If '$(vKey2)'<>'$(vKey3)' then

set vFlag=0;

ENDIF

//TRACE $(vTicketKey2) = $(vTicketKey3);

If '$(vTicketKey2)'<>'$(vTicketKey3)' then

set vFlag=1;

ENDIF

//Where  $(vKey)=$(vKey1) ;

NEXT i;

Thanks in advance.

1 Solution

Accepted Solutions
felipedl
Valued Contributor III

Re: App is running 10 hrs due to Loops and Peek????

Hi Ashok,

Instead of using loop and peek, you could only use load statements and peek.

I've developed an example with your data in the attached QVW.

I've put some comments but if you don't understand something, feel free to ask.

Final result is the green table below:

Sample.png

See if it helps you,

Felipe.

4 Replies
felipedl
Valued Contributor III

Re: App is running 10 hrs due to Loops and Peek????

Hi Ashok,

Instead of using loop and peek, you could only use load statements and peek.

I've developed an example with your data in the attached QVW.

I've put some comments but if you don't understand something, feel free to ask.

Final result is the green table below:

Sample.png

See if it helps you,

Felipe.

ashokvelisetty
New Contributor II

Re: App is running 10 hrs due to Loops and Peek????

Hi Felipe,

Thanks for quick response on this.

Let me go through the application and i will let you know the result.

Thanks,

Ashok.

ashokvelisetty
New Contributor II

Re: App is running 10 hrs due to Loops and Peek????

Hi Felipe,


Code is working as expected.

Thanks for your efforts, really i appreciate it.

Regards,

Ashok.

felipedl
Valued Contributor III

Re: App is running 10 hrs due to Loops and Peek????

No problem Ashok, glad it helped ,