cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
David_Morrow
Level II

Populate a table using table variables

I am trying to populate a table using the table variables. ( sample table attached)

The first 3 columns of the table are created from the table variable name and the 4th column is the table variable value

 

row 1   : target[0].target__reflectance_pc = 3  :Ambient_level W/m2 = 0    :zone_id_r =1  :Result = 400

row 2   : target[0].target__reflectance_pc = 3  :Ambient_level W/m2 = 0    :zone_id_r =2  :Result = 400 

row 3   : target[0].target__reflectance_pc = 3  :Ambient_level W/m2 = 10  :zone_id_r =1  :Result = 100

row 4   : target[0].target__reflectance_pc = 3  :Ambient_level W/m2 = 10  :zone_id_r =2  :Result = 100

 

And so on for all the table variables in the table

Any help with this would be much appreciated.  

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Populate a table using table variables

The below script will populate your data table with values from the Table Variables.  I have also attached a new version of your Test data table.  The one you had attached had a formula in one of the columns, which did not permit the table to populate.

Names Default To Here( 1 );
dt = Current Data Table();

tableVarNamesList = dt << get table variable names;

For( i = 1, i <= N Items( tableVarNamesList ), i++,
	dt << add rows( 1 );
	Column( dt, "target[0].target__reflectance_pc" )[i] =
	Num( Word( 2, tableVarNamesList[i], "," ) );
	Column( dt, "Ambient_level W/m2" )[i] =
	Num( Word( 3, tableVarNamesList[i], "," ) );
	Column( dt, "zone_id_r" )[i] = Num(
		Word( 4, tableVarNamesList[i], ",)" )
	);
	Column( dt, "result" )[i] = Num(
		dt << get table variable( tableVarNamesList[i] )
	);
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Populate a table using table variables

The below script will populate your data table with values from the Table Variables.  I have also attached a new version of your Test data table.  The one you had attached had a formula in one of the columns, which did not permit the table to populate.

Names Default To Here( 1 );
dt = Current Data Table();

tableVarNamesList = dt << get table variable names;

For( i = 1, i <= N Items( tableVarNamesList ), i++,
	dt << add rows( 1 );
	Column( dt, "target[0].target__reflectance_pc" )[i] =
	Num( Word( 2, tableVarNamesList[i], "," ) );
	Column( dt, "Ambient_level W/m2" )[i] =
	Num( Word( 3, tableVarNamesList[i], "," ) );
	Column( dt, "zone_id_r" )[i] = Num(
		Word( 4, tableVarNamesList[i], ",)" )
	);
	Column( dt, "result" )[i] = Num(
		dt << get table variable( tableVarNamesList[i] )
	);
);
Jim
David_Morrow
Level II

Re: Populate a table using table variables

Thank you that is exactly what I was trying to do.

Recommended Articles