<?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: Loop to find max value for each unique values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709505#M89342</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47878"&gt;@mmarchandTSI&lt;/a&gt;&amp;nbsp;Col max works only with :Barcode column. The issue is some table don't have Barcode column so am trying to see if I can use X and Y Coordinates to assign the max rn value in&lt;/P&gt;</description>
    <pubDate>Thu, 14 Dec 2023 18:10:29 GMT</pubDate>
    <dc:creator>Jackie_</dc:creator>
    <dc:date>2023-12-14T18:10:29Z</dc:date>
    <item>
      <title>Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708421#M89243</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to iterate over each values of X and Y and save the max rn value in the MaxValue column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried but something doesn't seem correct. Any advice?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

dt &amp;lt;&amp;lt; begin data table();

// Loop through rows
For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	currentBarcode = dt:Barcode[i];
   // Find the location of the maximum rn value for the current Barcode
	maxRNRow = Max( dt:rn[dt:Barcode[i] == currentBarcode] );
   // Check if the maxRNRow is not 0 (meaning there is at least one matching Barcode)
	If( maxRNRow != 0, 
       // Update "MaxValue" column with the max rn value for the current Barcode
		dt:MaxValue[i] = dt:rn[maxRNRow]
	);
);
dt &amp;lt;&amp;lt; end data table();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jackie__0-1702402546406.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/59562i076EC5849F89FEE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jackie__0-1702402546406.png" alt="Jackie__0-1702402546406.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 17:37:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708421#M89243</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-12-12T17:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708437#M89244</link>
      <description>&lt;P&gt;Try this instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Max( :rn, :Y, :X )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be clearer, set the formula for :MaxValue to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Max( :rn, :Barcode )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 17:47:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708437#M89244</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2023-12-12T17:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708468#M89252</link>
      <description>&lt;P&gt;No loops needed here. You can do what &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47878"&gt;@mmarchandTSI&lt;/a&gt; suggested and use Col Max with byvar, you could use Summarize to calculate the maximum values and then create new column using those or you could create summary table and join (or rather update) that to your table with the max value. Also the the begin/end messages are&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Begin Data Update;
dt &amp;lt;&amp;lt; End Data Update;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 18:37:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/708468#M89252</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-12T18:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709505#M89342</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/47878"&gt;@mmarchandTSI&lt;/a&gt;&amp;nbsp;Col max works only with :Barcode column. The issue is some table don't have Barcode column so am trying to see if I can use X and Y Coordinates to assign the max rn value in&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 18:10:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709505#M89342</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-12-14T18:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709511#M89343</link>
      <description>&lt;P&gt;You can add more than one byvar&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt &amp;lt;&amp;lt; New Column("Maximum Value for Each Age and Sex Group",
	Formula(Col Maximum(:height, :age, :sex))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1702578708979.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/59705i6EECD14B4C5766D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1702578708979.png" alt="jthi_0-1702578708979.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/statistical-functions-2.shtml?os=win&amp;amp;source=application#ww2752580" target="_self"&gt;Col Max()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 18:32:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709511#M89343</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-14T18:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loop to find max value for each unique values</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709522#M89344</link>
      <description>&lt;P&gt;Right, so the first formula I posted will work for what you're doing, as&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;alluded to.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 18:59:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-to-find-max-value-for-each-unique-values/m-p/709522#M89344</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2023-12-14T18:59:24Z</dc:date>
    </item>
  </channel>
</rss>

