cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
OC200m
Level II

Adding Calculation to summary table in JSL

Hi all, 

back with another question that has me stumped, trying to add a calculation to a summary by creating a new column. There is a column i am attempting to create named GD1 that I wish to sum the values in the columns N(4) and N(5) to, if they exist. Here is my attempt at checking for the existence of those columns and summing them if they exist, this seems to terminate in the debugger but I'm not seeing why:

Data Table( "Fun pull" ) << Summary(
	Group( :Name( "90440011_119325" ) ),
	N,
	Subgroup( :Sort_Lot ),
	Freq( "None" ),
	Weight( "None" );

	newcol1 = Expr(
		Current Data Table() << New Column( "GD1",
			Numeric,
			"Continuous",
			Formula( Sum( :Name( "N(1)" ), :Name( "N(2)" ), :Name( "N(3)" ) ) )
		)
	);
	Eval( Eval Expr( newcol1 ) );

	newcol2 = Expr(
		Current Data Table() << New Column( "Test",
			formula(
				If( Contains( Current Data Table() << get column names( string ), "N(4)" ),
					Sum( :GD1, Name( "N(4)" ) ),
					If( Contains( Current Data Table() << get column names( string ), "N(5)" ),
						Sum( :GD1, Name( "N(5)" ) ),
						Sum( :GD1 )
					)
				)
			)
		);
		Eval( Eval Expr( newcol2 ) );
	);
)

Any explanation as to how this can be implemented correctly would be greatly appreciated. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Adding Calculation to summary table in JSL

The primary issue with the JSL is that the closing parentheses for the Summary Platform, included all of the JSL for the creation of the new columns.  The Summary Platform needs to be completed and then the new columns are added.

Secondly, since the specifics of the actual names for the columns in the data table being created in the Summary Platform, there is not a need to use the complexity of code that you are attempting.  In my example below, I have simplified your code.

Third, I have changed your code to make data table references more specific to make the code more readable and to make sure JMP knows exactly what data table to work on.  Also, I changed the references to columns that have complex names from the structure

:Name( "name" )

to

:"name"n

which is the announced structure that will be used moving forward.

Data Table( "semiconductor capability" ) << Summary(
	Group( :"90440011_119325"n ),
	N,
	Subgroup( :Sort_Lot ),
	Freq( "None" ),
	Weight( "None" ),
	Output Table( "New Table" )
);

Data Table( "New Table" ) << New Column( "GD1",
	Numeric,
	"Continuous",
	Formula( Sum( :"N(1)"n, :"N(2)"n, :"N(3)"n ) )
);

Current Data Table() << New Column( "Test",
	formula(
		If( Contains( Data Table( "New Table" ) << get column names( string ), "N(4)" ),
			Sum( :GD1, :"N(4)"n ),
			If( Contains( Data Table( "New Table" ) << get column names( string ), "N(5)" ),
				Sum( :GD1, :"N(5)"n ),
				Sum( :GD1 )
			)
		)
	)
);

 

 

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Adding Calculation to summary table in JSL

The primary issue with the JSL is that the closing parentheses for the Summary Platform, included all of the JSL for the creation of the new columns.  The Summary Platform needs to be completed and then the new columns are added.

Secondly, since the specifics of the actual names for the columns in the data table being created in the Summary Platform, there is not a need to use the complexity of code that you are attempting.  In my example below, I have simplified your code.

Third, I have changed your code to make data table references more specific to make the code more readable and to make sure JMP knows exactly what data table to work on.  Also, I changed the references to columns that have complex names from the structure

:Name( "name" )

to

:"name"n

which is the announced structure that will be used moving forward.

Data Table( "semiconductor capability" ) << Summary(
	Group( :"90440011_119325"n ),
	N,
	Subgroup( :Sort_Lot ),
	Freq( "None" ),
	Weight( "None" ),
	Output Table( "New Table" )
);

Data Table( "New Table" ) << New Column( "GD1",
	Numeric,
	"Continuous",
	Formula( Sum( :"N(1)"n, :"N(2)"n, :"N(3)"n ) )
);

Current Data Table() << New Column( "Test",
	formula(
		If( Contains( Data Table( "New Table" ) << get column names( string ), "N(4)" ),
			Sum( :GD1, :"N(4)"n ),
			If( Contains( Data Table( "New Table" ) << get column names( string ), "N(5)" ),
				Sum( :GD1, :"N(5)"n ),
				Sum( :GD1 )
			)
		)
	)
);

 

 

Jim
OC200m
Level II

Re: Adding Calculation to summary table in JSL

Very clear explanation, much appreciated!