Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
mridgley
New Contributor

Repeat Rows based on Field

Hello,

I have a table similar to the one noted below. I am trying to replicate / repeat each record in the LOAD script by the number specified in [Months Remaining]:

The input table looks as follows:

TABLE:
LOAD
*
INLINE [
Region, Value, Months Remaining
Canada, 1500, 3

Canada, 700, 1

US 1000, 2];


I would like to have the following output:

Region, Value, Months Remaining
Canada, 1500, 3

Canada, 1500, 3

Canada, 1500, 3

Canada, 700, 1

US 1000, 2

US 1000, 2


As such, each record has been repeated and duplicated according to the number of [Months Remaining]. I would really appreciate any help with the code and/ or syntax as I am currently stuck.


1 Reply

Re: Repeat Rows based on Field

Hi Michael,

Try,

TABLE:
LOAD *
INLINE [
Region, Value, Months Remaining
Canada, 1500, 3
Canada, 700, 1
US, 1000, 2]
;

Final:
NoConcatenate
LOAD *,

RowNo() as Row
Resident TABLE
While IterNo()<=[Months Remaining];

DROP Table TABLE;

Untitled.png