I would like to stack a list of columns based on a table variable, but I'm having trouble figuring out how to format the variable and the script
//this is my table variable -- I've called it myList
{"colName1", "colName2"}//this is my script
dt = Current Data Table();
dt << Stack(
columns(myList),
Output Table( "New Table" )
);I have a table with column names colName1, colName2, colName3...
And I would like to be able to stack only certain columns based on a table variable list. I've been able to do this by grouping columns then stacking the whole group, but I've run into situations where I may want to stack a subset of a group of columns, hence this attempt.
The list and script above gives me the error: "Column not found in access or evaluation of bad argument"
I've also tried changing the command to
columns(eval(myList))but that gives me the same error
Taking a hint from this thread, I figured out that using the Parse() command works for this.
Table variable myList formatted as such:
{"colName1","colName2"}and script looks like this:
dt = Current Data Table();
dt << Stack
( columns( Parse(myList) ),
Output Table( "Stacked Data" )
);
@snapnpop ,
Shouldn't your table variable look like this ?
{"Column1", "Column2"} vs {"Column1, Column2"} ?
hello,
you can try with this code
dt = current data table();
// column dialog editor
cd = Column Dialog(
Var = collist( " select columns >>", MinCol( 1 ) ), Hlist( "" ), );
collist= cd["Var"];
//stack operation
dt_stack = dt << Stack(
columns( collist ), Output Table( "STacked" ),
);
Taking a hint from this thread, I figured out that using the Parse() command works for this.
Table variable myList formatted as such:
{"colName1","colName2"}and script looks like this:
dt = Current Data Table();
dt << Stack
( columns( Parse(myList) ),
Output Table( "Stacked Data" )
);