What if I have 2 columns with column names based on the input of data and I need to subtract them and store it in a column?
It's simple with the column name A and B and you can calculate A-B.
If the column name A||cyclecountvalue1 and B||cyclecountvalue2 , it gives me an error saying name unresolved.
Should I use associative array or complex function?
I really appreciate your help.
Assuming that you actually have a data column named A||cyclecountvalue1, then this should work: Name( "A||cyclecountvalue1" ) instead. The problem is that the original column name is not a valid JSL name, but the Name() function will return a valid reference that you can use instead.
I don't recommend using formulas unless the contents of a column must automatically update in the future, after the script is finished.
You could iterate over the rows with For Each Row() function but it would be messier, I think. Instead, vectorize the problem.
You can use this pattern:
data 1 = data column 1 << Get As Matrix;
data 2 = data column 2 << Get As Matrix;
Current Data Table() << New Column( "name", Values( data 1 - data 2 ) );
Of course you would iterate over all possible pairs of columns.