<?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: column with formula in a post query script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82533#M37191</link>
    <description>&lt;P&gt;If I understand this correctly, you should be able to avoid creating new columns by checking first if the column exists before executing that line of code.&amp;nbsp; Here's a way to do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(Contains(dt &amp;lt;&amp;lt; Get Column Names(string),"BMI")==0,
	dt &amp;lt;&amp;lt; NewColumn("BMI", Numeric, Continuous, Formula(:weight/:height^2));
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Nov 2018 15:41:38 GMT</pubDate>
    <dc:creator>cwillden</dc:creator>
    <dc:date>2018-11-05T15:41:38Z</dc:date>
    <item>
      <title>column with formula in a post query script</title>
      <link>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82514#M37182</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a JMP query builder, and with the post query script, I create a new column with something like this:&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; NewColumn("BMI", Numeric, Continuous, Formula(:weight/:height^2));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but, my problem&amp;nbsp;is: when&amp;nbsp;I update from database the jmp file, I create a new column "BMI 2".&lt;/P&gt;
&lt;P&gt;and with an another update: a new column BMI 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to have only one column BMI at each update from database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best regards&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 19:01:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82514#M37182</guid>
      <dc:creator>Françoise</dc:creator>
      <dc:date>2018-11-05T19:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: column with formula in a post query script</title>
      <link>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82531#M37190</link>
      <description>&lt;P&gt;Without more specifics, it is tough to say precisly what the solution is, but my initial thought is that you need to check to see if the column you are creating already exists, and if it does, then you either need to delete the existing column and then create the new column, or just skip the creation of the new column.&amp;nbsp; I am not sure which of these is correct, not knowing the logic and flow of your script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( try( column(dt, "the column name" ) &amp;lt;&amp;lt; get name, "" ) != "",
     dt &amp;lt;&amp;lt; delete columns( "the column name" );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 15:33:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82531#M37190</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-11-05T15:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: column with formula in a post query script</title>
      <link>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82533#M37191</link>
      <description>&lt;P&gt;If I understand this correctly, you should be able to avoid creating new columns by checking first if the column exists before executing that line of code.&amp;nbsp; Here's a way to do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(Contains(dt &amp;lt;&amp;lt; Get Column Names(string),"BMI")==0,
	dt &amp;lt;&amp;lt; NewColumn("BMI", Numeric, Continuous, Formula(:weight/:height^2));
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Nov 2018 15:41:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/column-with-formula-in-a-post-query-script/m-p/82533#M37191</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-11-05T15:41:38Z</dc:date>
    </item>
  </channel>
</rss>

