Choose Language Hide Translation Bar
Highlighted
BrianK
Level I

Passing a variable to the formula of a new column, which is a combination of variable and a static string.

 
1 REPLY 1
Highlighted
txnelson
Super User

Re: Passing a variable to the formula of a new column, which is a combination of variable and a static string.

Here is the way I would do it, to make sure the actual static values are in the formula, and not just referenced values

Names Default To Here( 1 );
dt = New Table( "example",
	add rows( 10 ),
	New Column( "VarLog", formula( Log( Random Integer( 1, 100 ) ) ) ),
	New Column( "VarSum", formula( Random Integer( 1, 100 ) + Random Integer( 1, 100 ) ) )
);

Eval(
	Substitute(
			Expr(
				dt << New Column( "new val", formula( __formula__ ) )
			),
		Expr( __formula__ ),
			Parse(
				"Var" || Right( Column( dt, 1 ) << get name, 3 ) || " - Var" ||
				Right( Column( dt, 2 ) << get name, 3 )
			)
	)
);
Jim
Article Labels

    There are no labels assigned to this post.