<?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 get max values accross multiple columns with missing data in their rows! in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276750#M53719</link>
    <description>Thanks txnelson for your great solution! You always helpful to go detail and explain things very clear!</description>
    <pubDate>Fri, 03 Jul 2020 06:16:43 GMT</pubDate>
    <dc:creator>joshua</dc:creator>
    <dc:date>2020-07-03T06:16:43Z</dc:date>
    <item>
      <title>How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276729#M53713</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets say we have data set that we want to get max values across the selected columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "Untitled",
	New Column( "a@b;2", Numeric, Set Values( [12, 33, 1] ) ),
	New Column( "b", Numeric, Set Values( [2, 11, 2] ) ),
	New Column( "c@d;3", Numeric, Set Values( [333, 1, 0] ) )
);

colnames = dt &amp;lt;&amp;lt; getcolumnnames;

use_cols = {};

include = {"@"};

For( j = 1, j &amp;lt;= N Items( include ), j++,

	For( i = 1, i &amp;lt;= Nitems( colnames  ), i++,
	If(Contains(colnames[i], include[j]),  
	insert into (use_cols , colnames[i]))
		
));


dt &amp;lt;&amp;lt; new column("max_col",numeric,formula(Maximum(use_cols)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="joshua_0-1593736661870.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25007iD364F2A0BB519801/image-size/medium?v=v2&amp;amp;px=400" role="button" title="joshua_0-1593736661870.png" alt="joshua_0-1593736661870.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I don't understand why it returns missing value in max_col ? Should we loop through the use_cols ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:15:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276729#M53713</guid>
      <dc:creator>joshua</dc:creator>
      <dc:date>2023-06-10T23:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276730#M53714</link>
      <description>Forgot to add sometimes columns may contain missing values as well. I could not figured out how to add them when I built the data table.&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Jul 2020 00:42:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276730#M53714</guid>
      <dc:creator>joshua</dc:creator>
      <dc:date>2020-07-03T00:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276731#M53715</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;You just need to help JMP figure out that the variable "use_cols" is referring to columns by adding "as columns" to your last statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "max_col", numeric, formula( Maximum( as columns( use_cols ) ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:49:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276731#M53715</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-07-03T14:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276746#M53716</link>
      <description>&lt;P&gt;Running on a Windows PC, running Windows 10, I went back several versions of JMP and ran your script, and it ran correctly on all versions.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="version.PNG" style="width: 489px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25008iB55EE9D5E316407C/image-size/large?v=v2&amp;amp;px=999" role="button" title="version.PNG" alt="version.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Your second qualification, that sometimes you have missing values in your data should not be an issue.&amp;nbsp; The Maximum() function handles missing values.&lt;/P&gt;
&lt;P&gt;Not knowing more about your script, I will point out a possible issue.&amp;nbsp; If you look at the formula that is created for the column max_col you will see:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="version2.PNG" style="width: 919px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25009iA79EAE76B668BA19/image-size/large?v=v2&amp;amp;px=999" role="button" title="version2.PNG" alt="version2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The formula relies on the list "use_cols", so every time the formula is run, or rerun, it go to the list and uses the value "at that point in time" of "use_cols" and places it into the formula.&amp;nbsp; If the value of "use_cols" is "&lt;FONT style="background-color: #ffffff;"&gt;{Name( "a@b;2" ), Name( "c@d;3" )}&lt;/FONT&gt;", everything will work fine.&amp;nbsp; If for some reason, the list "use_cols" has changed it's value, the formula may not work and you will get missing values.&amp;nbsp; What you really want is for the formula to be&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Maximum( {:Name( "a@b;2" ), :Name( "c@d;3" )} )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The easiest way to do this, in my experience, is to specify the new column and formula as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(Parse("dt &amp;lt;&amp;lt; new column(\!"max_col\!",numeric,formula( Maximum(" || char(use_cols) || ")));"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It results in the formula being specified as:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="version3.PNG" style="width: 916px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25021iC22A500EDF249435/image-size/large?v=v2&amp;amp;px=999" role="button" title="version3.PNG" alt="version3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 02:28:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276746#M53716</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-03T02:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276750#M53719</link>
      <description>Thanks txnelson for your great solution! You always helpful to go detail and explain things very clear!</description>
      <pubDate>Fri, 03 Jul 2020 06:16:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276750#M53719</guid>
      <dc:creator>joshua</dc:creator>
      <dc:date>2020-07-03T06:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max values accross multiple columns with missing data in their rows!</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276751#M53720</link>
      <description>Sorry! this did not work out!</description>
      <pubDate>Fri, 03 Jul 2020 06:17:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-max-values-accross-multiple-columns-with-missing-data/m-p/276751#M53720</guid>
      <dc:creator>joshua</dc:creator>
      <dc:date>2020-07-03T06:17:20Z</dc:date>
    </item>
  </channel>
</rss>

