dtt=Data table("inputdata");
//option 1, not working as desired
colc=dtt<<NewColumn("codefin",Formula(Char(:dates)||"_"||Char(:codes)));
IDs=dtt<<New Column( "ID",
Numeric,
Continuous,
Format( "Best", 8 ),
Formula(
If( Row() == 1,
1,
If( :codefin== Lag( :ID, 1 ),
Empty(),
Lag( :ID, 1 ) + 1
)
)
)
);
//option 2, not working
/*
//I started the following for loop, but I'm not sure how to complete it.
num= List(1, 2, 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28); only for 7 buildings and 4 days, for now.
For( n = 1, n <=7, n++,i=1, i<=4, i++, k=1, k<=28, k++
If((:codes(n)) & (:dates(i))),print(num(k)),28);
,n(i);
colname = Column( n ) <<
*/Hello,
I'm fairly new to JSL scripting, and I'm seeking help is writing a somewhat challenging if and/or for loop.
So I want to loop over two columns called “codes” and “dates” of different values to generate a specific number between 1-28 in a new column called “ID”.
The first columns has a repetition of numeric values ranging from 1-7. The second column has repetitive dates in this format, dd/mm/yyyy "dates". The third column is called “TestID” for the outputs.
My goal is to create a new column ”ID” that generates values 1-28 base on the following match.
that is when/if codes=1 & dates=1st date , the value in the new column is 1
then, when/if codes=1 & dates= 2nd date, the value in the new column is 2
then, when/if codes=1 & dates=3rd date ...newcolumn=3
then, when/if codes=1 & dates=4th date ...newcolumn=4
all over again...
then, when/if codes=2 & dates=3rd date ...newcolumn=5
then, when/if codes=2 & dates=4th date ...newcolumn=6
.
.
.
until,
then, when/if codes=7 & dates=4th date ...column=28
So far I have only been able to successfully write the attached above script , but it's not working as I desired.
This may be a bit challenging, but I'll apreciate any help.
Thank you!