cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
abmayfield
Level VI

Conditional transformations

I have a somewhat strange need, though I think it might actually be possible to achieve even without JSL. What I want is to transform certain columns based on a column property, specifically text. "If column has the following text: XYZ, then carry out this formula, else do nothing." I know how to do "if/then" formulas but is there a scripting syntax to only modify columns with certain properties? I have many columns, or else I'd simply do it manually!

Anderson B. Mayfield
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Conditional transformations

Here is the general structure of what you need to do....

names default to here(1);
dt=current data table();
colNames = dt << get column names(string);

for each({Name}, colNames,
	if(contains(Name,"nox"),
		for each row(
			column(name)[row()] = ???????????;  // your formula here
		)
	);
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Conditional transformations

Could you please clarify your statement

     "If column has the following text: XYZ, then carry out this formula, else do nothing."

Are you looking for XYZ being found in the column name, or in the any of the data values found in the column?

Jim
abmayfield
Level VI

Re: Conditional transformations

Thanks. Should have clarified. I am referring to the text in the column name rather than the actual data in the table’s cells. So: “if column name includes xyz, then do this transformation.”
Anderson B. Mayfield
txnelson
Super User

Re: Conditional transformations

Here is the general structure of what you need to do....

names default to here(1);
dt=current data table();
colNames = dt << get column names(string);

for each({Name}, colNames,
	if(contains(Name,"nox"),
		for each row(
			column(name)[row()] = ???????????;  // your formula here
		)
	);
);
Jim
abmayfield
Level VI

Re: Conditional transformations

Perfect! Thanks so much. I knew this functionality must exist!

Anderson B. Mayfield