<?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: Sort Columns in Descending Order and use 4 largest for calculation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241481#M47710</link>
    <description>&lt;P&gt;Here is an example of one way to do this.&amp;nbsp; I admit it is a little crazy, but it should show you some JCL that will give you an idea of what you can do.&amp;nbsp; I have done the calculation in a new column in the data table you displayed in your first inquiry.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nozzle.PNG" style="width: 808px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21004iC78BDF0A46690B03/image-size/large?v=v2&amp;amp;px=999" role="button" title="nozzle.PNG" alt="nozzle.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is the formula I developed for the new column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;theList = {};
Insert Into( theList, :Nozzle 1 );
Insert Into( theList, :Nozzle 2 );
Insert Into( theList, :Nozzle 3 );
Insert Into( theList, :Nozzle 4 );
Insert Into( theList, :Nozzle 5 );
Insert Into( theList, :Nozzle 6 );
theList = Sort Descending( theList );
theOutput = Char( theList[1] );
theOutput = theOutput || ", " || Char( theList[2] );
theOutput = theOutput || ", " || Char( theList[3] );
theOutput = theOutput || ", " || Char( theList[4] );
theOutput;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Jan 2020 05:38:18 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-01-16T05:38:18Z</dc:date>
    <item>
      <title>Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241461#M47703</link>
      <description>&lt;P&gt;I have a data table and I need to get the first 4 largest values from a range of columns, labeled "Nozzle #". These column values vary by variable, or column labeled "Test #".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="morenrx1_1-1579140890167.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21003i47E7478378C78ACC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="morenrx1_1-1579140890167.png" alt="morenrx1_1-1579140890167.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I then need to apply these values and in a new column calculate area of a circle per test #. Since I have a larger data table, I would like to either group the columns using the For, If, and Contains logic or is there a more efficient approach in JSL?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 02:27:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241461#M47703</guid>
      <dc:creator>morenrx1</dc:creator>
      <dc:date>2020-01-16T02:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241474#M47705</link>
      <description>Do you want the first 4 largest values across the Nozzle # columns for each row, or the first 4 largest values for all of the rows for all of the Nozzle # columns?</description>
      <pubDate>Thu, 16 Jan 2020 04:01:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241474#M47705</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-01-16T04:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241476#M47706</link>
      <description>I would like the first 4 largest Nozzle values per test. So, it would be:&lt;BR /&gt;18684 = 5.5 5 4 0&lt;BR /&gt;18685 = 5 5 4 0.5&lt;BR /&gt;18688 = 5.5 5 4 0.5&lt;BR /&gt;18689 = 5 5 0.5 0&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Jan 2020 04:18:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241476#M47706</guid>
      <dc:creator>morenrx1</dc:creator>
      <dc:date>2020-01-16T04:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241481#M47710</link>
      <description>&lt;P&gt;Here is an example of one way to do this.&amp;nbsp; I admit it is a little crazy, but it should show you some JCL that will give you an idea of what you can do.&amp;nbsp; I have done the calculation in a new column in the data table you displayed in your first inquiry.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nozzle.PNG" style="width: 808px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21004iC78BDF0A46690B03/image-size/large?v=v2&amp;amp;px=999" role="button" title="nozzle.PNG" alt="nozzle.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is the formula I developed for the new column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;theList = {};
Insert Into( theList, :Nozzle 1 );
Insert Into( theList, :Nozzle 2 );
Insert Into( theList, :Nozzle 3 );
Insert Into( theList, :Nozzle 4 );
Insert Into( theList, :Nozzle 5 );
Insert Into( theList, :Nozzle 6 );
theList = Sort Descending( theList );
theOutput = Char( theList[1] );
theOutput = theOutput || ", " || Char( theList[2] );
theOutput = theOutput || ", " || Char( theList[3] );
theOutput = theOutput || ", " || Char( theList[4] );
theOutput;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jan 2020 05:38:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241481#M47710</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-01-16T05:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241663#M47740</link>
      <description>&lt;P&gt;So I tried putting the columns into a list using a for loop, shown as&amp;nbsp;&lt;EM&gt;List1st&lt;/EM&gt; in the nozzle_script.jsl file. Whenever I try sorting them, only the column names are sorted and not the column values. I also tried using the code you have shown and the lists are shown as empty in the Log, shown below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="morenrx1_0-1579218521689.png" style="width: 669px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21022iBE711D843FEF54D0/image-dimensions/669x121?v=v2" width="669" height="121" role="button" title="morenrx1_0-1579218521689.png" alt="morenrx1_0-1579218521689.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My overall goal would be something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="morenrx1_1-1579218605945.png" style="width: 878px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21023i3D99F432EB66AAFE/image-dimensions/878x367?v=v2" width="878" height="367" role="button" title="morenrx1_1-1579218605945.png" alt="morenrx1_1-1579218605945.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(note: I manually entered the "Largest" column values. Then applied ("Largest"/4)^2 formula for the "Area" columns.)&lt;/P&gt;&lt;P&gt;I have attached the data table and my script below. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 23:53:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241663#M47740</guid>
      <dc:creator>morenrx1</dc:creator>
      <dc:date>2020-01-16T23:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241668#M47742</link>
      <description>&lt;P&gt;Try using this form&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
theList = {};
For( i = 2, i &amp;lt;= 7, i++,
	Eval( Parse( "Insert Into( theList," || Char( Column( dt, i )[Row()] ) || ")" ) )
);
theList = Sort Descending( theList );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jan 2020 00:35:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241668#M47742</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-01-17T00:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241680#M47745</link>
      <description>&lt;P&gt;Tried it out, code shown below, but it gives me all the values sorted.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;theList = {};
For( i = 2, i &amp;lt;= 7, i++,
	For Each Row(
		Eval( Parse( "Insert Into( theList," || Char( Column( dt, i )[Row()] ) || ")" ) )
	)
);
theList = Sort Descending( theList );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Yielding,&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 814px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21024iC715F1791A69F0B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 02:44:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241680#M47745</guid>
      <dc:creator>morenrx1</dc:creator>
      <dc:date>2020-01-17T02:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Columns in Descending Order and use 4 largest for calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241694#M47746</link>
      <description>&lt;P&gt;Please take a look at the first formula I gave you.&amp;nbsp; It first creates a list of all of the values for the different columns for the given row.&amp;nbsp; It then sorts the values and finally it takes the first four values into a character string.&lt;/P&gt;
&lt;P&gt;If you add that code to the latest code, it will result in a value for the column that contains the first 4 largest values.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 05:16:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-Columns-in-Descending-Order-and-use-4-largest-for/m-p/241694#M47746</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-01-17T05:16:56Z</dc:date>
    </item>
  </channel>
</rss>

