Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

1 Solution

Accepted Solutions
Not applicable
Author

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.

View solution in original post

17 Replies
Anonymous
Not applicable
Author

Can anyone help?

marcel_olmo
Partner Ambassador
Partner Ambassador

What do you mean with break?

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

This is what you get right now. Right?

DATAPARCELAS
1
2
3
4
5
6
7
4082720
408377
Anonymous
Not applicable
Author

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
Partner Ambassador
Partner Ambassador

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
Author

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.

Anonymous
Not applicable
Author

Beauty, solved my problem.

Thanks.

Not applicable
Author

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



Anonymous
Not applicable
Author

Fernando,

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

Not applicable
Author

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