<?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 JSL conditional multiple if statement comparing values in two columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246858#M48470</link>
    <description>&lt;P&gt;In my data table I want to compare values in two different columns and put results of comparison in a new column. I am able to make it work using a formula but not able to convert it into JSL. I need formula below as JSL script.&lt;/P&gt;&lt;P&gt;If MHD &amp;lt; MTV * -6 =&amp;gt; 0&lt;/P&gt;&lt;P&gt;If MHD &amp;gt; MTV * 6 =&amp;gt; 0&lt;/P&gt;&lt;P&gt;Else =&amp;gt; 1&lt;/P&gt;&lt;P&gt;Here MHD and MTV are two data columns with numeric continuous values. I am comparing values in these two columns for each row.&lt;/P&gt;&lt;P&gt;I tried script below but it does not work.&lt;/P&gt;&lt;P&gt;New Column ("P/F", Numeric, "Nominal", Formula(If(:MHD &amp;lt; :MTV * -6, 0, :MHD &amp;gt; :MTV*6, 0, 1)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance will be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2020 04:36:39 GMT</pubDate>
    <dc:creator>rverma</dc:creator>
    <dc:date>2020-02-11T04:36:39Z</dc:date>
    <item>
      <title>JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246858#M48470</link>
      <description>&lt;P&gt;In my data table I want to compare values in two different columns and put results of comparison in a new column. I am able to make it work using a formula but not able to convert it into JSL. I need formula below as JSL script.&lt;/P&gt;&lt;P&gt;If MHD &amp;lt; MTV * -6 =&amp;gt; 0&lt;/P&gt;&lt;P&gt;If MHD &amp;gt; MTV * 6 =&amp;gt; 0&lt;/P&gt;&lt;P&gt;Else =&amp;gt; 1&lt;/P&gt;&lt;P&gt;Here MHD and MTV are two data columns with numeric continuous values. I am comparing values in these two columns for each row.&lt;/P&gt;&lt;P&gt;I tried script below but it does not work.&lt;/P&gt;&lt;P&gt;New Column ("P/F", Numeric, "Nominal", Formula(If(:MHD &amp;lt; :MTV * -6, 0, :MHD &amp;gt; :MTV*6, 0, 1)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance will be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 04:36:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246858#M48470</guid>
      <dc:creator>rverma</dc:creator>
      <dc:date>2020-02-11T04:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246868#M48472</link>
      <description>&lt;P&gt;There is a small issue with JSL in handling &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; :MTV * -6&lt;/P&gt;
&lt;P&gt;JSL can be looking at -6 as a subtraction, not as a negative number.&amp;nbsp; Therefore it is wiser to reference it as&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; :MTV * (-6)&lt;/P&gt;
&lt;P&gt;to insure JMP interprets it correctly.&lt;/P&gt;
&lt;P&gt;Below are a couple of different ways to set the formula to get the results you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column ("P/F", Numeric, "Nominal", Formula(If(:MTV *(-6) &amp;lt; :MDH &amp;lt; :MTV * 6,1,0)))
//or
New Column ("P/F", Numeric, "Nominal", Formula(If(:MTV *(-6) &amp;lt; :MDH | :MDH &amp;gt; :MTV * 6,0,1)))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 05:46:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246868#M48472</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-02-11T05:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246958#M48483</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Formula( If( :MDH &amp;lt; :MTV * -6 | :MDH &amp;gt; :MTV * 6, 0, 1 ) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;maybe?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 12:23:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/246958#M48483</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2020-02-11T12:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247088#M48509</link>
      <description>Thank you. This solution worked perfectly too.</description>
      <pubDate>Wed, 12 Feb 2020 02:26:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247088#M48509</guid>
      <dc:creator>rverma</dc:creator>
      <dc:date>2020-02-12T02:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247126#M48515</link>
      <description>Thank you for the quick response and great ideas to solve the issue. My script is working now. One more thing I noticed was that if any of the column labels had a '-' or '&amp;amp;' then script would fail to work. Once those special characters were removed script worked without any issues.</description>
      <pubDate>Wed, 12 Feb 2020 04:13:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247126#M48515</guid>
      <dc:creator>rverma</dc:creator>
      <dc:date>2020-02-12T04:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247130#M48517</link>
      <description>&lt;P&gt;JSL is interpreting the &amp;amp; etc. as a computational element, not as something that is part of a name.&amp;nbsp; Take a look at the :Name() function that you can place around a column name to make sure JSL interprets the column name correctly..&lt;/P&gt;
&lt;P&gt;If you MDH column was named MDH/PQR JSL would interpret the name as a mathematical calculation of dividing a variable called MDH by a variable called PQR.&amp;nbsp; But if you reference it as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; :Name( "MDH/PQR" )&lt;/P&gt;
&lt;P&gt;all will work fine. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code it would look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column ("P/F", Numeric, "Nominal", Formula(If(:MTV *(-6) &amp;lt; :Name("MDH/PQR") &amp;lt; :MTV * 6,1,0)))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 04:27:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247130#M48517</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-02-12T04:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: JSL conditional multiple if statement comparing values in two columns</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247146#M48518</link>
      <description>Thanks for the great tip. Now I don't have to change my column labels which uses special characters.</description>
      <pubDate>Wed, 12 Feb 2020 05:16:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-conditional-multiple-if-statement-comparing-values-in-two/m-p/247146#M48518</guid>
      <dc:creator>rverma</dc:creator>
      <dc:date>2020-02-12T05:16:33Z</dc:date>
    </item>
  </channel>
</rss>

