<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding Calculation to summary table in JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591048#M79519</link>
    <description>&lt;P&gt;Very clear explanation, much appreciated!&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2023 13:04:50 GMT</pubDate>
    <dc:creator>OC200m</dc:creator>
    <dc:date>2023-01-18T13:04:50Z</dc:date>
    <item>
      <title>Adding Calculation to summary table in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591001#M79516</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Fun pull" ) &amp;lt;&amp;lt; Summary(
	Group( :Name( "90440011_119325" ) ),
	N,
	Subgroup( :Sort_Lot ),
	Freq( "None" ),
	Weight( "None" );

	newcol1 = Expr(
		Current Data Table() &amp;lt;&amp;lt; 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() &amp;lt;&amp;lt; New Column( "Test",
			formula(
				If( Contains( Current Data Table() &amp;lt;&amp;lt; get column names( string ), "N(4)" ),
					Sum( :GD1, Name( "N(4)" ) ),
					If( Contains( Current Data Table() &amp;lt;&amp;lt; get column names( string ), "N(5)" ),
						Sum( :GD1, Name( "N(5)" ) ),
						Sum( :GD1 )
					)
				)
			)
		);
		Eval( Eval Expr( newcol2 ) );
	);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any explanation as to how this can be implemented correctly would be greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:42:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591001#M79516</guid>
      <dc:creator>OC200m</dc:creator>
      <dc:date>2023-06-08T16:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Calculation to summary table in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591037#M79518</link>
      <description>&lt;P&gt;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.&amp;nbsp; The Summary Platform needs to be completed and then the new columns are added.&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp; In my example below, I have simplified your code.&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;what data table to work on.&amp;nbsp; Also, I changed the references to columns that have complex names from the structure&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:Name( "name" )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:"name"n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is the announced structure that will be used moving forward.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "semiconductor capability" ) &amp;lt;&amp;lt; Summary(
	Group( :"90440011_119325"n ),
	N,
	Subgroup( :Sort_Lot ),
	Freq( "None" ),
	Weight( "None" ),
	Output Table( "New Table" )
);

Data Table( "New Table" ) &amp;lt;&amp;lt; New Column( "GD1",
	Numeric,
	"Continuous",
	Formula( Sum( :"N(1)"n, :"N(2)"n, :"N(3)"n ) )
);

Current Data Table() &amp;lt;&amp;lt; New Column( "Test",
	formula(
		If( Contains( Data Table( "New Table" ) &amp;lt;&amp;lt; get column names( string ), "N(4)" ),
			Sum( :GD1, :"N(4)"n ),
			If( Contains( Data Table( "New Table" ) &amp;lt;&amp;lt; get column names( string ), "N(5)" ),
				Sum( :GD1, :"N(5)"n ),
				Sum( :GD1 )
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 12:31:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591037#M79518</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-01-18T12:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Calculation to summary table in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591048#M79519</link>
      <description>&lt;P&gt;Very clear explanation, much appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 13:04:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-Calculation-to-summary-table-in-JSL/m-p/591048#M79519</guid>
      <dc:creator>OC200m</dc:creator>
      <dc:date>2023-01-18T13:04:50Z</dc:date>
    </item>
  </channel>
</rss>

