<?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: Evaluating a variable column list as a string and inserting into a new column formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194241#M41519</link>
    <description>&lt;P&gt;Another community member may have a more efficient piece of code, but here is how I would code your request&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
VarCols = {"NPN1", "PNP2", "NPN2"};

VarName = "NewCol";

// Create the JSL required to generate the new column
theExpr = "DT &amp;lt;&amp;lt; New Column(VarName, Numeric, Continuous, formula(Maximum(:" || VarCols[1];
For( i = 2, i &amp;lt;= N Items( VarCols ), i++,
	theExpr = theExpr || ",:" || VarCols[i]
);
theExpr = theExpr || ")));";
// Run the generated JSL
Eval( Parse( theExpr ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Apr 2019 03:32:37 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2019-04-24T03:32:37Z</dc:date>
    <item>
      <title>Evaluating a variable column list as a string and inserting into a new column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194232#M41518</link>
      <description>&lt;P&gt;I've created a variable that is a string of column names.&amp;nbsp; This is inside a FOR loop so it will change with each loop.&lt;/P&gt;&lt;P&gt;Here is a sample table for demonstration, in reality my table is about 400 columns with weird names.&amp;nbsp; I'm trying to group columns that should be grouped and report the max value. 99.9% of the time there will only be 1 value per row for each 'like' column that is to be grouped.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Col1&lt;/TD&gt;&lt;TD&gt;Col2&lt;/TD&gt;&lt;TD&gt;Col3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This first part is a loop that generates a variable column list.&amp;nbsp; I don't have all the code here but here is a summary.&amp;nbsp; This works so I don't want to bog down the discussion in this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;VarCols = functional code here and the output is a string with this format: {"col1", "col2", "col3"}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then my code is supposed to create a new column named 'VarName' (defined in another part of the loop) then insert a formula that reports the max value of whichever columns are in VarCols.&amp;nbsp; But I just can't get it to evaluate.&amp;nbsp; Am I doing this way wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;DT &amp;lt;&amp;lt; New Column(VarName, Numeric, "Continuous", formula(Maximum(columns(eval(VarCols)))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is the specific error though i inserted the variable column name to avoid confusion:&lt;/P&gt;&lt;P&gt;Column VarName Formula Interrupted&lt;BR /&gt;Name Unresolved: columns 1 times At rows: 2 Operation: columns, columns( Eval( VarCols) ) /*###*/&lt;BR /&gt;Formula evaluation errors have been ignored&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 01:28:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194232#M41518</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2019-04-24T01:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a variable column list as a string and inserting into a new column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194241#M41519</link>
      <description>&lt;P&gt;Another community member may have a more efficient piece of code, but here is how I would code your request&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
VarCols = {"NPN1", "PNP2", "NPN2"};

VarName = "NewCol";

// Create the JSL required to generate the new column
theExpr = "DT &amp;lt;&amp;lt; New Column(VarName, Numeric, Continuous, formula(Maximum(:" || VarCols[1];
For( i = 2, i &amp;lt;= N Items( VarCols ), i++,
	theExpr = theExpr || ",:" || VarCols[i]
);
theExpr = theExpr || ")));";
// Run the generated JSL
Eval( Parse( theExpr ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Apr 2019 03:32:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194241#M41519</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-04-24T03:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a variable column list as a string and inserting into a new column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194306#M41541</link>
      <description>&lt;P&gt;That worked, thanks&amp;nbsp;&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, 24 Apr 2019 14:50:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/194306#M41541</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2019-04-24T14:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a variable column list as a string and inserting into a new column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/570862#M78083</link>
      <description>&lt;P&gt;&lt;EM&gt;Long time fan. First time I actually need to post to get a question answered.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is great. I just managed to get to that same point in my code. The next step is to inser this string into a function in a new column.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( "MinValue", numeric, continuous, Formula( min(Eval( Parse( TheExpr)))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but that is not working for me. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please ignore. Brain was not working right late tonight...&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 05:16:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/570862#M78083</guid>
      <dc:creator>SimFred</dc:creator>
      <dc:date>2022-11-18T05:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating a variable column list as a string and inserting into a new column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/570865#M78084</link>
      <description>&lt;P&gt;Please provide the value of "TheExpr"&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 05:51:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Evaluating-a-variable-column-list-as-a-string-and-inserting-into/m-p/570865#M78084</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-11-18T05:51:15Z</dc:date>
    </item>
  </channel>
</rss>

