<?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: How to use max among several column with &amp;quot;get rows where&amp;quot; condition in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80776#M36914</link>
    <description>&lt;P&gt;I think this might be a solution for what you are attempting to do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;min_value = Col Quantile( If( Row() &amp;lt;=64 &amp;amp; ( :target_status == 5 |
     :target_status == 9 ), 
     :median_range_mm
     , 
     .
     ), .5&lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Oct 2018 03:47:45 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-10-25T03:47:45Z</dc:date>
    <item>
      <title>How to use max among several column with "get rows where" condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80247#M36899</link>
      <description>&lt;P&gt;It seems an easy question but I'm struggling to solve it...&lt;/P&gt;&lt;P&gt;I have this kind of data table&amp;nbsp; :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 615px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/13037iC495B261B3750CE1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It goes until 64 which is the parameter "dim" in my script.&lt;/P&gt;&lt;P&gt;I'm looking for the maximum and minimum of all median_range_mm 1, 2 , 3 ... until 64. But I don't want JMP to look at rows where target_status is different of 5 or 9.&lt;/P&gt;&lt;P&gt;As you can see, when target status is 10 it overranges at 39996.&lt;/P&gt;&lt;P&gt;It is easier to understand with my code&amp;nbsp; :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;maxValueVar = 0 ;
maxValue = Max( :median_range_mm [dt &amp;lt;&amp;lt; get rows where( :target_status == 5 | :target_status == 9 ) ] );
minValue = Min( :median_range_mm[dt &amp;lt;&amp;lt; get rows where( :target_status == 5 | :target_status == 9 )] );
For( p = 2, p &amp;lt;= dim, p++,
	name = Column(dt, "target_status " || Char( p ));
	nom = Column(dt, "median_range_mm " || Char( p )); // browse every columns of median_range_mm
	MaxValueVar =  Col Max( nom [dt &amp;lt;&amp;lt; get rows where ( name == 5 | name == 9 )] );

	
	If(
		maxValueVar &amp;gt; maxValue, maxValue = maxValueVar,
		minValueVar &amp;lt; minValue, minValue = minValueVar
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Notice that It works for the first column that I didn't parametered. Also It works if I comment&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;[dt &amp;lt;&amp;lt; get rows where ( name == 5 | name == 9 )]&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any idea of how "get rows where" or "column max () " work ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:03:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80247#M36899</guid>
      <dc:creator>Rob128</dc:creator>
      <dc:date>2018-10-24T14:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use max among several column with "get rows where" condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80467#M36904</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12254"&gt;@Rob128&lt;/a&gt;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I am struggling to understand exactly what you want ?&amp;nbsp;Let me try and show you some steps:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;The following should give you all the rows, where target_status is either 5 or 9, like you have tried.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;SR = dt &amp;lt;&amp;lt; Select Where(:target_status ==5 | :target_status ==9) &amp;lt;&amp;lt; get selected rows; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Now, you have the list of rows where your condition is met, the next thing you want if I understand your question is the min and macimum value ?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;MedianValues = dt:median_range_mm &amp;lt;&amp;lt; Get Values; 

MedianValuesDes = MedianValues[SR]; // Filter out and get only the rows with target status of 5 or 9 

MaxVal = Max(MedianValuesDes ); 
MinVal = Min(MedianValuesDes ); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I am pretty sure there are many more ways to do it, but I am trying to break it down into steps so you can follow the thought. If this is not what you are after, can you explain a little more clearly what you are after please&amp;nbsp; ?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 18:39:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80467#M36904</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-10-24T18:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use max among several column with "get rows where" condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80776#M36914</link>
      <description>&lt;P&gt;I think this might be a solution for what you are attempting to do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;min_value = Col Quantile( If( Row() &amp;lt;=64 &amp;amp; ( :target_status == 5 |
     :target_status == 9 ), 
     :median_range_mm
     , 
     .
     ), .5&lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2018 03:47:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80776#M36914</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-10-25T03:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use max among several column with "get rows where" condition</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80779#M36916</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thank you for your answers. Maybe I wasn't clear enough in stating my problem indeed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main blocking point is that I can get the Maximum of the column "median_range_mm" with the filter on the column "target_status" with code :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;maxValue = Max( :median_range_mm [dt &amp;lt;&amp;lt; get rows where( :target_status == 5 | :target_status == 9 ) ] ); // ==&amp;gt; OK
minValue = Min( :median_range_mm[dt &amp;lt;&amp;lt; get rows where( :target_status == 5 | :target_status == 9 )] ); // ==&amp;gt; OK&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But once I&amp;nbsp;iterate over columns&amp;nbsp;:&lt;/P&gt;&lt;PRE&gt;For( p = 2, p &amp;lt;= dim, p++,&lt;BR /&gt; name = Column("target_status " || Char( p ));&lt;BR /&gt; nom = Column("median_range_mm " || Char( p ));&lt;BR /&gt; MaxValueVar = Max( nom [dt &amp;lt;&amp;lt; get rows where ( name == 5 | name == 9 )] );&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;MaxValueVar and MinValueVar get&amp;nbsp;no data "." (I guess it is&amp;nbsp;&lt;SPAN&gt;Missing Value character for numeric columns)&lt;/SPAN&gt; .&lt;/P&gt;&lt;P&gt;On debugging window I think the type of "name" and "nom" matters. It's not a column type...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is that "name" is the column "target_status 2" then 3 then 4 ... with iteration on p.&lt;/P&gt;&lt;P&gt;Same idea with "nom" which is the column "median_range_mm 2" then 3 then&amp;nbsp; 4 ....&lt;/P&gt;&lt;P&gt;So for p = 2,&amp;nbsp; I'm looking for the maximum of median_range_mm 2 where "target_status 2" == 5 or 9.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then p = 3 ... until 64&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, if "maximum of median_range_3" &amp;gt; "maximum of median_range_2" then "maximum of median_range_3 takes the maxValue :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
		MaxValueVar &amp;gt; maxValue, maxValue = MaxValueVar,
		MinValueVar &amp;lt; minValue, minValue = MinValueVar
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks for reading,&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 08:09:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-max-among-several-column-with-quot-get-rows-where/m-p/80779#M36916</guid>
      <dc:creator>Rob128</dc:creator>
      <dc:date>2018-10-26T08:09:09Z</dc:date>
    </item>
  </channel>
</rss>

