Skip to main content
Announcements
YOUR OPINION MATTERS! Please take the Qlik Experience survey you received via email. Survey ends June 14.
cancel
Showing results for 
Search instead for 
Did you mean: 
mohamed_ahid
Partner - Specialist
Partner - Specialist

load inside loop

i'm trying to construct this table :

[Semaine Analyse],

[Key Client] ,

Week,

[Transaction V0]

[Transaction V1]

using two load inside one loop .

Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V0]

         resident Transactions

         where week ([Key Date])>=$(Semaine1) and week ([Key Date])<=$(Semaine2)

         group by  [Key Client], week([Key Date]) ;

and

Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V1]

         resident Transactions

         where week ([Key Date])>=$(Semaine3) and week ([Key Date])<=$(Semaine4)

         group by  [Key Client], week([Key Date]) ;

the loop :

For v = 1 to 27

   

      Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

       Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

    

  the place of my load

          

            

      Next v

how to do that plz ?

thx

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

May be try kind of this

TableA:

Load * Inline

[

Semaine Analyse, Key Client, Week, Transaction V0, Transaction V1

];

For v = 1 to 27

  

      Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

       Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

     Concatenate(TableA)

     Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V0]

         resident Transactions

         where week ([Key Date])>=$(Semaine1) and week ([Key Date])<=$(Semaine2)

         group by  [Key Client], week([Key Date]) ;

     Concatenate(TableA)

     Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V1]

         resident Transactions

         where week ([Key Date])>=$(Semaine3) and week ([Key Date])<=$(Semaine4)

         group by  [Key Client], week([Key Date]) ;            

Next v

View solution in original post

10 Replies
mohamed_ahid
Partner - Specialist
Partner - Specialist
Author

anyone have an idea ?

tresesco
MVP
MVP

Your construct looks good. Could you share your sample qvw? What is the exact issue you are facing?

mohamed_ahid
Partner - Specialist
Partner - Specialist
Author

thx for respondig ,

its working but i'm getting two tables .and that's what i don't want .

what y need is one table  having this structure :

[Semaine Analyse],

[Key Client] ,

Week,

[Transaction V0]

[Transaction V1]

and using the two loads .

MayilVahanan

Hi

Combine both the tables by using the key word "Concatenate".

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
tresesco
MVP
MVP

Use Concatenate keyword between the two tables.

mohamed_ahid
Partner - Specialist
Partner - Specialist
Author

it's giving bad results (calculation ) .The script create me 27 tables

DavidFoster1
Specialist
Specialist

Either use concatenate (which will double the number of rows) or use a left join between the tables (but this requires identical keys in the tables)

CELAMBARASAN
Partner - Champion
Partner - Champion

May be try kind of this

TableA:

Load * Inline

[

Semaine Analyse, Key Client, Week, Transaction V0, Transaction V1

];

For v = 1 to 27

  

      Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

       Let    Semaine1 = week(Today())-($(v)*2);

      let    Semaine2 = week(Today())-($(v)*2)+$(v)-1;

     Concatenate(TableA)

     Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V0]

         resident Transactions

         where week ([Key Date])>=$(Semaine1) and week ([Key Date])<=$(Semaine2)

         group by  [Key Client], week([Key Date]) ;

     Concatenate(TableA)

     Load

         $(v) as [Semaine Analyse],

         [Key Client] ,

         week([Key Date]) as Week,

         sum([Montant payé]) as [Transaction V1]

         resident Transactions

         where week ([Key Date])>=$(Semaine3) and week ([Key Date])<=$(Semaine4)

         group by  [Key Client], week([Key Date]) ;            

Next v

mohamed_ahid
Partner - Specialist
Partner - Specialist
Author

the solution is to begane by create an empty table .

thx all