How to fix a variable in a column formula<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi,
thanks to a script, I want to create a column with a formula which contain a variable as follow:
dt=current data table();
variable1=10;
dt<<new column("exemple", numeric, continu, formula(:othercolumn*variable1));
I would like this result in the column formula:
:othercolumn*10
But, I have :othercolumn*variable1.
Any idea of how to fixe the variable?
Re: How to fix a variable in a column formulaFormula() does not evaluate its argument expression (which makes sense); the expression is just passed on to the data table and evaluated there. Thus the variable must be evaluated before creating the column. Below is one way to do it (see other approaches in earlier as I'm sure this issue has been up before).
Eval(Eval Expr(dt << New Column("exemple", numeric, formula(:othercolumn * Expr(variable1)))));