I am generating new columns by adding some columns. The columns to add, I get the names from a file and build the names as a array list. The column names and number of columns could change. When the number of columns change, I am having to edit the formula to reflect the change. Using the column names array list, is there a way of dynamically adding them in the formula, without having to specify every column I want to add,
dt=current data table();
Cols=Associative Array();
Cols["A1"]={ColA, ColB, ColC};
Cols["A2"]={ColE, ColF, ColG};
Cols["abc"]={"Total1", Total2};
newcolExpr = Expr (
dt << New Column(Counts["abc"][1], Numeric, Continuous, Formula( If(Expr(Cols["A1"][1]) + Expr(Cols["A1"][2]) + Expr(Cols["A1"][3]) > 0,1,0)));
dt << New Column(Counts["abc"][2], Numeric, Continuous, Formula( If(Expr(Cols["A2"][1]) + Expr(Cols["A2"][2]) + Expr(Cols["A2"][3]) > 0,1,0)));
);
Eval(Eval Expr( newColExpr));
I would appreciate any suggestions for my problem.
Thanks!