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

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
tamilarasu
Champion
Champion

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