<?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: Sorting and Adding a new column with formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412632#M66221</link>
    <description>&lt;P&gt;The scripting index under the Help menu has some useful information for you here.&amp;nbsp; I searched for 'sort' this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ih_0-1629917993220.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35318iA742F3CBC9C00B9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ih_0-1629917993220.png" alt="ih_0-1629917993220.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are happy with the formula you used for the % Total column, you can use the scripting index to find a function to create a new column in the data table.&amp;nbsp; Or, you could use the&lt;LI-MESSAGE title="Scripting Tools" uid="410943" url="https://community.jmp.com/t5/JMP-Add-Ins/Scripting-Tools/m-p/410943#U410943" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;add-in to install a function called 'Copy Column Script' to the cols menu. Then you can just select the column, copy the script, and paste that in your script. If I understand your requirement for that column though you could just divide the N Row column by the sum of the column N Row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Putting that together might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

// The function from your example:
dtSummarized = dt &amp;lt;&amp;lt; &amp;lt;&amp;lt; Summary(
	Group(
		:Open VIO,
		:Open SCLK,
		:Open SDATA,
		:Open USID,
		:Open RF1,
		:Open RF2,
		:Open RF3,
		:Open RF4,
		:Open RFC
	),
	Freq( "None" ),
	Weight( "None" )
);

// dtSummarized = Current Data Table();

// From Scripting Index
dtSummarized &amp;lt;&amp;lt; Sort( replace table, By( :N Rows ), Order( Descending ) );

// From Scripting Tools Add-in
New Column("% Total", Numeric, "Continuous", Format("Percent", 12, 2), Formula(:N Rows / Col Sum(:N Rows)), Set Display Width(44));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 19:11:46 GMT</pubDate>
    <dc:creator>ih</dc:creator>
    <dc:date>2021-08-25T19:11:46Z</dc:date>
    <item>
      <title>Sorting and Adding a new column with formula</title>
      <link>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412568#M66215</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to sort column N Rows in descending order and add a new column which shows the % of total of N Rows. Please help me out with the jsl script&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_0-1629906424202.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35317i183BEB49F7F71B19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1629906424202.png" alt="Jacksmith12_0-1629906424202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt; Summary(
	Group(
		:Open VIO,
		:Open SCLK,
		:Open SDATA,
		:Open USID,
		:Open RF1,
		:Open RF2,
		:Open RF3,
		:Open RF4,
		:Open RFC
	),
	Freq( "None" ),
	Weight( "None" )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:55:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412568#M66215</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T19:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and Adding a new column with formula</title>
      <link>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412573#M66216</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 15:50:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412573#M66216</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-25T15:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and Adding a new column with formula</title>
      <link>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412631#M66220</link>
      <description>&lt;P&gt;Here is a script that works.&amp;nbsp; Please note that since JMP will generate the jsl you need, when you run interactively, you should be able to create your own code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "original data" ) &amp;lt;&amp;lt; Summary(
	Group(
		:Open VIO, :Open SCLK, :Open SDATA, :Open USID, :Open RF1, :Open RF2,
		:Open RF3, :Open RF4, :Open RFC
	),
	"% of Total"n,
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 ),
	output table( "Summarized Table" )
);
Data Table( "Summarized Table") &amp;lt;&amp;lt; sort(by(:N Rows), order(descending), replace table(1));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Aug 2021 19:08:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412631#M66220</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-25T19:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and Adding a new column with formula</title>
      <link>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412632#M66221</link>
      <description>&lt;P&gt;The scripting index under the Help menu has some useful information for you here.&amp;nbsp; I searched for 'sort' this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ih_0-1629917993220.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35318iA742F3CBC9C00B9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ih_0-1629917993220.png" alt="ih_0-1629917993220.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are happy with the formula you used for the % Total column, you can use the scripting index to find a function to create a new column in the data table.&amp;nbsp; Or, you could use the&lt;LI-MESSAGE title="Scripting Tools" uid="410943" url="https://community.jmp.com/t5/JMP-Add-Ins/Scripting-Tools/m-p/410943#U410943" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;add-in to install a function called 'Copy Column Script' to the cols menu. Then you can just select the column, copy the script, and paste that in your script. If I understand your requirement for that column though you could just divide the N Row column by the sum of the column N Row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Putting that together might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

// The function from your example:
dtSummarized = dt &amp;lt;&amp;lt; &amp;lt;&amp;lt; Summary(
	Group(
		:Open VIO,
		:Open SCLK,
		:Open SDATA,
		:Open USID,
		:Open RF1,
		:Open RF2,
		:Open RF3,
		:Open RF4,
		:Open RFC
	),
	Freq( "None" ),
	Weight( "None" )
);

// dtSummarized = Current Data Table();

// From Scripting Index
dtSummarized &amp;lt;&amp;lt; Sort( replace table, By( :N Rows ), Order( Descending ) );

// From Scripting Tools Add-in
New Column("% Total", Numeric, "Continuous", Format("Percent", 12, 2), Formula(:N Rows / Col Sum(:N Rows)), Set Display Width(44));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 19:11:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sorting-and-Adding-a-new-column-with-formula/m-p/412632#M66221</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2021-08-25T19:11:46Z</dc:date>
    </item>
  </channel>
</rss>

