<?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: Apply Mathematical formula only on Selected Rows (JSL) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/453720#M70052</link>
    <description>&lt;P&gt;I have similar situation with a data table. My goal is to convert all of the values in the "Values" column from Fahrenheit to Celsius. The script I am using to do this is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(If(:Unit=="°F", Selected(RowState())=1));
For Each Row(:Value = If(Selected(RowState(Row())), Conversions:Farenheit To Celsius(:Value)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script does what I need it to do in terms of the conversion however, all of the values that are not associated with the unit&amp;nbsp;°F are removed. Is there a script that can be added to ignore the unselected columns and ultimately keep the values that are not associated with the unit&amp;nbsp;°F?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MROW_0-1643048379719.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39254i6C01D695D9CE4B23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MROW_0-1643048379719.png" alt="MROW_0-1643048379719.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jan 2022 19:09:34 GMT</pubDate>
    <dc:creator>MROW</dc:creator>
    <dc:date>2022-01-24T19:09:34Z</dc:date>
    <item>
      <title>Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61382#M33254</link>
      <description>&lt;P&gt;How do I apply a mathmatical formula to selected rows only using JSL? Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 20:43:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61382#M33254</guid>
      <dc:creator>twillkickers</dc:creator>
      <dc:date>2018-06-26T20:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61632#M33260</link>
      <description>&lt;P&gt;You did not mention if you just want the value or you wanted this to be another column formula. If it is s column formula you need to provide more information.&amp;nbsp; Here is an exampe with a computation using only 2 of 6 rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt = new Table("Test", Add Rows(6), New Column("Values", numeric, continuous, Set Values(J(6,1, Random Integer(1,20))) ) );

mysum = :Values[2]^2 + :Values[4]^2 - 4 * :Values[2]*:Values[4] ;

show(mysum );

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 23:32:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61632#M33260</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-06-26T23:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61639#M33265</link>
      <description>&lt;P&gt;Here is an example that shows how to deal exclusively&amp;nbsp;with selected rows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// pause to show the original data table
wait(5);

// select some rows
dt &amp;lt;&amp;lt; select where( :sex == "F" );

For( i = 1, i &amp;lt;= N Rows( dt &amp;lt;&amp;lt; get selected rows ), i++,
	dt:age[i] = dt:age[i] - 2
);

dt:weight[dt&amp;lt;&amp;lt;get selected rows] = 100;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 02:55:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61639#M33265</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-27T02:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61655#M33276</link>
      <description>&lt;P&gt;Here is an example of my interpretation of what you want to do.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 795px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/11283i668F7758D058E136/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last column uses a column formula. The formula implements the conditional computation.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 802px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/11284iFE7DD68680F39F6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Row states are a vital part of how JMP operates. This code is equivalent but without installing a column formula.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

col = Current Data Table() &amp;lt;&amp;lt; New Column( "Conditional BMI" );

For Each Row( col[] = If( Selected( Row State( Row() ) ), (703 * :weight) / :height ^ 2 ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 10:18:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/61655#M33276</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-06-27T10:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/453720#M70052</link>
      <description>&lt;P&gt;I have similar situation with a data table. My goal is to convert all of the values in the "Values" column from Fahrenheit to Celsius. The script I am using to do this is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(If(:Unit=="°F", Selected(RowState())=1));
For Each Row(:Value = If(Selected(RowState(Row())), Conversions:Farenheit To Celsius(:Value)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script does what I need it to do in terms of the conversion however, all of the values that are not associated with the unit&amp;nbsp;°F are removed. Is there a script that can be added to ignore the unselected columns and ultimately keep the values that are not associated with the unit&amp;nbsp;°F?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MROW_0-1643048379719.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39254i6C01D695D9CE4B23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MROW_0-1643048379719.png" alt="MROW_0-1643048379719.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 19:09:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/453720#M70052</guid>
      <dc:creator>MROW</dc:creator>
      <dc:date>2022-01-24T19:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Mathematical formula only on Selected Rows (JSL)</title>
      <link>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/453723#M70053</link>
      <description>&lt;P&gt;I wouldn't really suggest directly converting the value of Value field because unless you also change the Unit column to Celsius.&lt;/P&gt;
&lt;P&gt;You can use set each value with if-statement to replace values in column. In else part "return" same value there is currently. Something like this should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:Value &amp;lt;&amp;lt; Set Each Value(
	If(:Unit=="°F" /*&amp;amp; Selected()*/,
		Conversions:Farenheit To Celsius(:Value)
	, //else keep value
		:Value 
	);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 18:39:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Apply-Mathematical-formula-only-on-Selected-Rows-JSL/m-p/453723#M70053</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-01-24T18:39:05Z</dc:date>
    </item>
  </channel>
</rss>

