Hello,
I have a list of strings that are column names. I want to determine their column location(i) in a data table and then add a new column with the formula( Column( i ) + Column( i+1 )). My code looks like this:
cols = dt << Get Column Names( St
ring);
list = { "B", "D"};
n = N Items( list);
locate = {}:
For( i=1, i<=n, i++,
locate = Loc( dt, list);
New Column( "New", Formula( Column( locate) + Column( locate + 1)))
);
I am having trouble because Loc() returns a matrix and Column() can only evaluate a number. I want my final data table to look like this:
| A | B | C | D | E | F | New | New 2 |
|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 5 | 9 |
| 1 | 2 | 3 | 4 | 5 | 6 | 5 | 9 |
| 1 | 2 | 3 | 4 | 5 | 6 | 5 | 9 |
| 1 | 2 | 3 | 4 | 5 | 6 | 5 | 9 |
Can anyone help me out?