<?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: What is the best way to calculate with table variables and columns? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66871#M34512</link>
    <description>&lt;P&gt;Thanks for your solution. It works fine. However, after the JSL was executed and I do readjust the table variable "Quantile" and "Threshold" the new column :D1 is only responding on changes on "Threshold" and not on changes on "Quantile". Could this be fixed?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;There are multiple ways to do this without having a table formula and table variables using set values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since your script used a formula, this alternative JSL uses a formula. If you can get by without a column formula, other methods can be used, including a script to prompt for quantile, threshold then recalculate qq and recalculate D1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Create Table Variable
dt = currentdatatable();
dt &amp;lt;&amp;lt; Set Table Variable( "Quantile", 0.9 );
dt &amp;lt;&amp;lt; Set Table Variable( "Threshold", 1 );

_xx = dt &amp;lt;&amp;lt; get rows where(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold);
dt &amp;lt;&amp;lt; Set Table Variable("QQ", Quantile(dt:Quantile, dt:D0[_xx] ));
dt &amp;lt;&amp;lt; New Column("D1",  Numeric, Continuous, 
  Formula( If(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold &amp;amp; :D0&amp;lt; :QQ, :D0) )
);


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your solution. It works fine. However, after the JSL was executed and I do readjust the table variable "Quantile" and "Threshold" the new column :D1 is only responding on changes on "Threshold" and not on changes on "Quantile".&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Aug 2018 09:34:58 GMT</pubDate>
    <dc:creator>Thomas1</dc:creator>
    <dc:date>2018-08-07T09:34:58Z</dc:date>
    <item>
      <title>What is the best way to calculate with table variables and columns?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66806#M34497</link>
      <description>&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;A JSL (TestJSL) script creates two table variables. Within the script they are being used to calculate a new column :D1 from the existing column :D0 by applying IF states etc..&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Is there a better way to do this, than with the rather complex formula for :D1?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 22:32:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66806#M34497</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2018-08-06T22:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate with table variables and columns?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66830#M34505</link>
      <description>&lt;P&gt;There are multiple ways to do this without having a table formula and table variables using set values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since your script used a formula, this alternative JSL uses a formula. If you can get by without a column formula, other methods can be used, including a script to prompt for quantile, threshold then recalculate qq and recalculate D1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Create Table Variable
dt = currentdatatable();
dt &amp;lt;&amp;lt; Set Table Variable( "Quantile", 0.9 );
dt &amp;lt;&amp;lt; Set Table Variable( "Threshold", 1 );

_xx = dt &amp;lt;&amp;lt; get rows where(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold);
dt &amp;lt;&amp;lt; Set Table Variable("QQ", Quantile(dt:Quantile, dt:D0[_xx] ));
dt &amp;lt;&amp;lt; New Column("D1",  Numeric, Continuous, 
  Formula( If(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold &amp;amp; :D0&amp;lt; :QQ, :D0) )
);


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 06:47:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66830#M34505</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-08-07T06:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate with table variables and columns?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66871#M34512</link>
      <description>&lt;P&gt;Thanks for your solution. It works fine. However, after the JSL was executed and I do readjust the table variable "Quantile" and "Threshold" the new column :D1 is only responding on changes on "Threshold" and not on changes on "Quantile". Could this be fixed?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;There are multiple ways to do this without having a table formula and table variables using set values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since your script used a formula, this alternative JSL uses a formula. If you can get by without a column formula, other methods can be used, including a script to prompt for quantile, threshold then recalculate qq and recalculate D1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Create Table Variable
dt = currentdatatable();
dt &amp;lt;&amp;lt; Set Table Variable( "Quantile", 0.9 );
dt &amp;lt;&amp;lt; Set Table Variable( "Threshold", 1 );

_xx = dt &amp;lt;&amp;lt; get rows where(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold);
dt &amp;lt;&amp;lt; Set Table Variable("QQ", Quantile(dt:Quantile, dt:D0[_xx] ));
dt &amp;lt;&amp;lt; New Column("D1",  Numeric, Continuous, 
  Formula( If(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold &amp;amp; :D0&amp;lt; :QQ, :D0) )
);


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your solution. It works fine. However, after the JSL was executed and I do readjust the table variable "Quantile" and "Threshold" the new column :D1 is only responding on changes on "Threshold" and not on changes on "Quantile".&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 09:34:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66871#M34512</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2018-08-07T09:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate with table variables and columns?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66874#M34515</link>
      <description>&lt;P&gt;Well your formula worked, so you could use that. I agree that formula is a difficult one to maintain.&lt;/P&gt;&lt;P&gt;Here is an alternative, add a script to the table. I added the JSL (after the wait(5) ) that shows how to change the quantile and threshold and run the script. Or interactively, change the 2 variables and click on Update D1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use whichever method you find easiest for you to use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Create Table Variable
dt = currentdatatable();
dt &amp;lt;&amp;lt; Set Table Variable( "Quantile", 0.9 );
dt &amp;lt;&amp;lt; Set Table Variable( "Threshold", 1 );
dt &amp;lt;&amp;lt; New Column("D1",  Numeric, Continuous);
dt &amp;lt;&amp;lt; New Script ("Update D1",
   dt = current data table();
  _xx = dt &amp;lt;&amp;lt; get rows where(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold);
  dt &amp;lt;&amp;lt; Set Table Variable("QQ", Quantile(dt:Quantile, dt:D0[_xx] ));
   qq = Quantile(dt:Quantile, dt:D0[_xx] );
   //caption(char(qq)); wait(2); caption(remove); //uncomment to test
  dt:D1 &amp;lt;&amp;lt; Set Each Value(
    If(:P1 ==0 &amp;amp; :P2 &amp;lt;:Threshold &amp;amp; :D0&amp;lt; qq, :D0, empty()) 
 );
);
wait(5);
dt &amp;lt;&amp;lt; Set Table Variable( "Quantile", 0.6 );
dt &amp;lt;&amp;lt; Set Table Variable( "Threshold", 1.8 );
dt &amp;lt;&amp;lt; Run Script("Update D1") ;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Aug 2018 10:14:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66874#M34515</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-08-07T10:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate with table variables and columns?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66896#M34519</link>
      <description>&lt;P&gt;Thanks again. Now it works, by running the update script. The charm of the formula is that the data update is automatically done. Is it risky to do this with the formula for about 100k rows (avoiding errors ….)? If I stick with the formula would it be better to generate an column :DT in which to first part is being calculated If( :P1 == 0 &amp;amp; :P2 &amp;lt; :Threshold, :D0 ) What would a script look like in case there are several: D0a :D0b columns in order to generate the corresponding : D1a, .D1b columns?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 12:47:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-best-way-to-calculate-with-table-variables-and/m-p/66896#M34519</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2018-08-07T12:47:51Z</dc:date>
    </item>
  </channel>
</rss>

