Hi everyone,
First time I'm writing here, though I have read in this forum a lot.
I do have some experience in JSL scripting, but I still haven't dealt with for loops.
I have this data table which has 5 columns: entity, date1, date2, value1, value2 (value2 column initially contains missing values only).
The table is sorted by Entity (ascending) and date1 (descending).
I want to loop through all rows, and insert values from value1 column into value2 column, based on the following condition:
IF entity[row i] == entity[row j] AND date1[row i] > date2[row j] THEN insert the value from value1[row j] into value2[row i]
Once a value is inserted, just continue to the next row.
So far I have this:
dt = Current Data Table();
For( i = 1, i <= N Rows( dt ), i++,
For( j = i, j <= N Rows( dt ), j++,
If(
And(
Column( dt, "entity" )[i] == Column( dt, "entity" )[j],
Column( dt, "date1" )[i] > Column( dt, "date2" )[j]
),
Column( dt, "value2" )[i] = Column( dt, "value1" )[j];
Break();
)
)
);
But I'm not getting any values inserted to value2.
I would love to get some help on this. Hope I explained myself well.
Thanks