Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to create a loop by refering 2 columns

hi all,

Please find the attached file (which contains sample source file and example for required output).

Please help me to create a column from the below source file using 'START_RANGE' & 'END_RANGE'.

s1.png

I need to generate a table like below (Just given a sample for first 4 Rows)

s2.png

Thanks in advance!!!

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Hi,

Check this..

Directory;

T1:

LOAD Col1,

     Col2,

     Col3,

     Col4,

     Col5,

     Col6,

     Col7,

     Col8,

     Col9,

     Col10,

     Col11,

     Col12,

     START_RANGE,

     END_RANGE,

     F15

FROM

source.xlsx

(ooxml, embedded labels, table is [sample date]);

NoConcatenate

T2:

LOAD *,RowNo() as Key,Num(END_RANGE)-Num(START_RANGE) as Count Resident T1 Where not IsNull(Col2);

DROP Table T1;


Final:

LOAD * Inline [

Temp

''

];

for i = 1 to NoOfRows('T2')

  Let vCount=Peek('Count',i-1,'T2');

  for j=1 to $(vCount)+1

  Concatenate(Final)

  LOAD *,Num(START_RANGE+$(j)-1,Repeat('0',Len(START_RANGE))) as Result Resident T2 Where Key=$(i);

  Next j

Next i

DROP Table T2;

DROP Field Temp,Key,Count;

Capture.JPG

Check the Attachment.

View solution in original post

4 Replies
settu_periasamy
Master III
Master III

Hi,

Check this..

Directory;

T1:

LOAD Col1,

     Col2,

     Col3,

     Col4,

     Col5,

     Col6,

     Col7,

     Col8,

     Col9,

     Col10,

     Col11,

     Col12,

     START_RANGE,

     END_RANGE,

     F15

FROM

source.xlsx

(ooxml, embedded labels, table is [sample date]);

NoConcatenate

T2:

LOAD *,RowNo() as Key,Num(END_RANGE)-Num(START_RANGE) as Count Resident T1 Where not IsNull(Col2);

DROP Table T1;


Final:

LOAD * Inline [

Temp

''

];

for i = 1 to NoOfRows('T2')

  Let vCount=Peek('Count',i-1,'T2');

  for j=1 to $(vCount)+1

  Concatenate(Final)

  LOAD *,Num(START_RANGE+$(j)-1,Repeat('0',Len(START_RANGE))) as Result Resident T2 Where Key=$(i);

  Next j

Next i

DROP Table T2;

DROP Field Temp,Key,Count;

Capture.JPG

Check the Attachment.

Anonymous
Not applicable
Author

HI

Thank you so much

Anonymous
Not applicable
Author

hi Settu thanks

i have one more issue when i am trying to create a 'start range' and 'end range' getting the issue below. please advise

test.png

settu_periasamy
Master III
Master III

Hi,

Can you post your qvw which is not working?

May be check the attachment.. i just did a small change in the previous script..