Hi All,
This question is in relation to a post here that nicely generates a non-dynamic column for summing up a list of other columns.
The problem I am having is how to sum up the columns (using JSL) when you have a list of N other columns and have it be a dynamic formula.
I have a list of columns in my data table, say ColList, and I want to generate a new column with a formula that simply sums the N items in the ColList. Something I was thinking is like this:
Names Default to Here (1);
dt = Open("$Sample_Data/2D Gaussian Process Example.jmp");<BR />ColList = dt << Get Column Names;
dt << New Column("Sum", Formula(Sum(ColList))); This clearly doesn't work because ColList is a list of columns: ColList = {"col1", "col2", ..., "colN"}. I have tried to make a string and using the Eval(Parse()) and Eval Insert() like such:
Names Default to Here (1);
dt = Current Data Table();
str = Eval Insert("dt << New Column(\!"Sum\!", Formula(Sum(Eval(ColList))));");
Eval(Parse(str)); But still no luck. The JSL code will generate the column with a formula, but will have empty row values because it still shows Eval(ColList) in the formula instead of it being the actual formula, which should look like: Sum(:col1, :col2, :col3, ..., :colN).
I can't figure out what I'm doing wrong in going from the list {""} of columns to the reference to the columns with the colon :.
Any help is much appreciated.
Thanks!,
DS