Eval Expr not workingAlways confused by this one. I created this formula based on one that worked previously.
// Get the current data table
dt = Current Data Table();
colNames = dt << get column names( continuous, string );
// Loop through all columns
For each( {col}, colNames,
Eval(
Eval Expr(
New Column(
Expr( col ) || "_Gouge",
Numeric,
"Continuous",
Format( "Best", 10 ),
Formula( (Mean( As Column( Eval(col) ) [Index(1, 100)]) + Mean(As Column(Eval(col)) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(As Column(Eval(col)) ) )
);
)
);
);
Formula appears to remain unevaluated.
Automation and ScriptingRe: Eval Expr not workingAs Column( Eval( col ) ) should be As Column( Expr( col ) );
Re: Eval Expr not workingFinished thing looks like this.
// Get the current data table
dt = Current Data Table();
colNames = dt << get column names( continuous, string );
// Loop through all columns
For each( {col}, colNames,
Eval(
Eval Expr(
New Column(
Expr( col ) || "_Gouge",
Numeric,
"Continuous",
Format( "Best", 10 ),
Formula( (Mean( As Column( Expr( col ) ) [Index(1, 100)]) + Mean(As Column( Expr( col ) ) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(As Column( Expr( col )) ) )
);
)
);
);Re: Eval Expr not workingYou could also use the below code. It will create column references which look as if the column was added in Formula Editor.
One of the benefits: when the input column is renamed, the formula still works.
dt = Current Data Table();
colNames = dt << get column names( continuous, string );
// Loop through all columns
For each( {col}, colNames,
Eval(
Eval Expr(
New Column(
col || "_Gouge",
Numeric,
"Continuous",
Format( "Best", 10 ),
Formula( (Mean( Expr(Name Expr(As Column( col ) )) [Index(1, 100)]) + Mean(Expr(Name Expr(As Column( col ) )) [Index(N Rows() - 99, N Rows())])) / 2 - Col Minimum(Expr(Name Expr(As Column( col )) )) )
);
)
);
);