Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

washington
Contributor

LOOP

Because this script just a record breaking quantities of parts?

tmp:

load * inline[

DATA, PARCELAS

'11/10/2011',20

'21/10/2011',7

];

LET X = peek('PARCELAS');

LET Z = peek('DATA');

FOR i = 1 to $(x)

load * inline

[

DATA, PARCELAS

$(z),$(i)

];

next i

Tags (1)
1 Solution

Accepted Solutions
Not applicable

LOOP

did you mean this?

tmp:
load * inline [
DATA, PARCELAS
'11/10/2011',20
'21/10/2011',7
];

Counts:
LOAD Count(PARCELAS) as Y
Resident tmp;

LET y = Peek('Y', 0) - 1;
DROP Table Counts;

for k = 0 to $(y)

LET x = peek('PARCELAS', $(k));
LET z = peek('DATA', $(k));

FOR i = 1 to $(x)

load * inline [
DATA, PARCELAS
$(z),$(i)
];

next i

NEXT k


But be aware about duplication of two first records.

17 Replies
washington
Contributor

LOOP

Can anyone help?

marcel_olmo
Contributor III

LOOP

What do you mean with break?

Which is your desired result? Maybe if you are more specific, we can help you easily. Smiley Wink

This is what you get right now. Right?

DATAPARCELAS
1
2
3
4
5
6
7
4082720
408377
washington
Contributor

LOOP

Exactly.
This is what I have now.
You can observe that the value did not break 20.

My table is comprised of several records with different field plots.

In my example, I posted only two record, just one more record breaking obeyed.

marcel_olmo
Contributor III

LOOP

Sorry Washington, I still don't get you when you say "the value did not break 20" ¿?

Could you put an example of your desired result, like I showed you my final table result before?

Thank you.

Not applicable

LOOP

did you mean this?

tmp:
load * inline [
DATA, PARCELAS
'11/10/2011',20
'21/10/2011',7
];

Counts:
LOAD Count(PARCELAS) as Y
Resident tmp;

LET y = Peek('Y', 0) - 1;
DROP Table Counts;

for k = 0 to $(y)

LET x = peek('PARCELAS', $(k));
LET z = peek('DATA', $(k));

FOR i = 1 to $(x)

load * inline [
DATA, PARCELAS
$(z),$(i)
];

next i

NEXT k


But be aware about duplication of two first records.

washington
Contributor

LOOP

Beauty, solved my problem.

Thanks.

Not applicable

LOOP

Hi,

I change the script for not duplicate.


Datas:
load * inline [
DATA, PARCELAS
'11/10/2011',20
'21/10/2011',7
];


FOR k = 0 TO (NoOfRows('Datas')-1)

LET data = peek('DATA', $(k));
LET parcela = peek('PARCELAS', $(k));

FOR i = 1 to ($(parcela)-1)

load
Date('$(data)') as DATA,
'$(i)' as PARCELAS
Autogenerate(1);

NEXT i

NEXT k



washington
Contributor

LOOP

Fernando,

Because in your example the second record did not break like the original?

Not applicable

LOOP

Washington,

I did a test here and it worked properly.

Following is the table with the data.

DATA PARCELAS count(DATA&PARCELAS)
27
11/10/201111
11/10/201121
11/10/201131
11/10/201141
11/10/201151
11/10/201161
11/10/201171
11/10/201181
11/10/201191
11/10/2011101
11/10/2011111
11/10/2011121
11/10/2011131
11/10/2011141
11/10/2011151
11/10/2011161
11/10/2011171
11/10/2011181
11/10/2011191
11/10/2011201
21/10/201111
21/10/201121
21/10/201131
21/10/201141
21/10/201151
21/10/201161
21/10/201171
Community Browser