Choose Language Hide Translation Bar
Highlighted
ENTHU
Community Trekker

access and repeat row values

I am trying to write a code where I can get value from a row and then repeat it in 13 successive rows of the same column.

I want to read value from row number 15 and repeat in rows 16 to 28.

Then read value from row number 29 and repeat until row 43 so on and so forth.

How can I do this in jsl?

 

Thanks

0 Kudos
2 REPLIES 2
txnelson
Super User

Re: access and repeat row values

This is a very simple thing for one to do in JSL.  Below is my version of the code.  I don't know what the name of the column is that you want to change the values for, so I am just calling it "theColumn".  I really haven't tested the code, but I am pretty sure it will work

Names Default To Here( 1 );
dt = Current Data Table();

For( i = 1, i <= N Rows( dt ), i = i + 14,
	For( k = i + 1, k <= i + 13, k++,
		dt:theColumn[k] = dt:theColumn[i]
	)
);
Jim
ms
Super User ms
Super User

Re: access and repeat row values

If you want to keep the original column, you could add a new column with a formula. For example:

New Column("Repeat14",
    Formula(
        If(Row() > 14,
            :OriginalCol[Row() - Mod(Row() - 1, 14)],
            :OriginalCol
        )
    )
);