Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have this Table
Temp2:
Indiv, Date, week, DonnCalcul
100, 03/01/2011, 1, 2
100, 04/01/2011, 1, 3
100, 10/01/2011, 2, 2
100, 13/01/2011, 2, 4
200, 05/01/2011, 1, 5
200, 06/01/2011, 1, 3
200, 20/01/2011, 3, 6
I want to do nested loops to calculate the data.
I want to do a loop
- For each individual
o For each week
For all dates (for the week of the individual)
Have you any idea how to write loops?
How i know when i change indiv, week??
Thank you for your help...
What are you trying to loop through?
If you want to test records or do accumulation within script, you will want to use the interrecord functions.
Peek() is a good one to start with.
You can peek() at the previous record and test with if conditions to determine if the Indiv or week has changed.
Hello!
Yes I use Peek() function.
my problem is to manage the change in value.
If I do an if (peek (Invidi, i) <> peek (indiv, i +1)) how I treat the last line of the same individual.
How I can have this final table:
Indiv, week, DonnCalcul
100, 1, 5
100, 2, 6
200, 1, 8
200, 3, 6
I hope I was clear enough and you can help me ...
Hi,
you need not loop through for getting the totals.. you should use script aggregation functions by using group by..
Please see the attached sample can give you some idea on how to use aggreagation.. please go through the Qlikview help for further info on aggreagation..
Cheers.
I can do group by since i need to read each road..
My loop is :
For each person (2 loop since 2 individus)
Var1 = x
For each week (4 loop 2 by individus)
CompteurHeures=0
for each row of TEMP2 (7 loop in 2 times)
Var2=CompteurHeures
Var3=CompteurHeures+XX
SI Var3 <= Var1
Si Var2 = "HeuresJours"
Var5='XX'
VAR6='YY'
Si Var2= "HeuresNuits"
VAR5='TTT'
VAR6='YY'
….