BookmarkSubscribeSubscribe to RSS Feed

In JSL having trouble adding a new column to a newly transposed datatable

shankyjain

Community Trekker

Joined:

Nov 11, 2013

Here is the complete log


Log output:

 

 

Column not found in access or evaluation of 'Bad Argument'
 
Send Expects Scriptable Object in access or evaluation of 'Send' , dt_3 << New Column( "Dev", Character, Nominal, "Source" )
 
In the following script, error marked by /*###*/
dt_1 = Current Data Table();
cc = dt_1 << Get Column Names;
cc[3] << Set Selected( 1 );
For( i = 36, i <= 58, i++,
  cc << Set Selected( 1 )
);
dt_2 = dt_1 << Subset( Selected, Output Table Name( "I_tmp" ) );
cc = dt_2 << Get Column Names;
ncols = N Items( cc );
For( i = 2, i <= ncols, i++,
  cc << Set Selected( 1 )
);
dt_3 = dt_2 << Transpose(
  columns( Selected ),
  By( :Column 1 ),
  Output Table Name( "I" )
);
dt_3 << /*###*/New Column( "Dev", Character, Nominal, "Source" ) /*###*/;
{}

 

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

:Column 1 refers to Column("Column 1") whereas Column(1) refers to the first column. Column(dt_3, 1) refers to the first column in data table dt_3.

4 REPLIES
shankyjain

Community Trekker

Joined:

Nov 11, 2013

Found Partial Answer: Had to change columns(Selected) to (Selected) in

dt_3 = dt_2 << Transpose(
columns( Selected ),
By( :Column 1 ),
Output Table Name( "I" )
);

But, my way referring to first column as :Column 1 in By() is not working. Is there as way to refer to columns by say first, second rather than their actual names?

ms

Super User

Joined:

Jun 23, 2011

Solution

:Column 1 refers to Column("Column 1") whereas Column(1) refers to the first column. Column(dt_3, 1) refers to the first column in data table dt_3.

shankyjain

Community Trekker

Joined:

Nov 11, 2013

Column(1) refers to first column in table you mean, then i can give Transpose(columns(1,5,8), By(column(4))..... right?

ms

Super User

Joined:

Jun 23, 2011

Yes, that should work.

(Sorry, I've edited my confusing typos in previous post)