You will have to evaluate the variables to formulas . This is still a good referenceInsert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute (thought it could use some updates). Here is one option using Eval(Substitute()) (for simple case like this, I would use Eval(EvalExpr()) which hogi did demonstrate)
Names Default To Here(1);
new_col = Eval(Substitute(
Expr(mycol << New Column("belowCount", Numeric,
Formula(If(col_to_check < _limit_val_, 1, 0))
)),
Expr(col_to_check), Name Expr(AsColumn(mycol, 1)),
Expr(_limit_val_), limit_val
));
And full example
Names Default To Here(1);
limit_val = 5;
mycol = New Table("Untitled",
Add Rows(10),
Compress File When Saved(1),
New Column("Column 1", Numeric, "Continuous", Set Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
);
new_col = Eval(Substitute(
Expr(mycol << New Column("belowCount", Numeric,
Formula(If(col_to_check < _limit_val_, 1, 0))
)),
Expr(col_to_check), Name Expr(AsColumn(mycol, 1)),
Expr(_limit_val_), limit_val
));

-Jarmo