Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Duplicate rows based on field quantity

Dear all,

I have a table as shown below.

  

CodeQty
A0011
A0021
B0012
B0023

I am trying to achieve the breakdown of quantity to 1 unit per row.

How do I go about using a 'for loop' to duplicate the records? Or suggest any better methods.

  

CodeQty
A0011
A0021
B0011
B0011
B0021
B0021
B0021

The above is just a simple example. There could be multiple fields.

Thanks in advance!

3 Replies
sunny_talwar

May using While loop...

LOAD Code,

     1 as Qty

FROM ...

While IterNo() <= Qty;

sunny_talwar

Here is a sample script using Inline load

LOAD RowNo() as RowNum,

Code,

1 as Qty

While IterNo() <= Qty;

LOAD * INLINE [

    Code, Qty

    A001, 1

    A002, 1

    B001, 2

    B002, 3

];


Capture.PNG

tamilarasu
Champion
Champion

I think both of you are working in the same/similar project/office as you both have same question.

How to skip values in for .. next  loops