<?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 Using specific row values for use in a formula with JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40163#M23507</link>
    <description>&lt;P&gt;I would like to do something that I learnt a long time ago in VB, but am struggling with JMP scripting language. I am new to JMP.&lt;/P&gt;&lt;P&gt;I would like to run a For loop in a formula but use a cell array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I know I can reference a column as follows: j = Column ("a");&lt;/P&gt;&lt;P&gt;If I then say j[4] = 77 + 2; &amp;nbsp;&amp;nbsp;I will get the value 79 in column “a”, row 4.&lt;/P&gt;&lt;P&gt;What, though, if I wanted to run a loop on Column "a", for example For(i=1,i&amp;lt;=20,i++, &lt;FONT face="arial black,avant garde"&gt;SOME FORMULA USING&lt;/FONT&gt; j[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the attachment I would like to use column-B Row [1] with column-C’s Rows 1 to 5. And then, column-B Row [6] with column-C’s Rows 6 to 10. My aim is to use the sequence in Column-A as an identifier, hence each time the sequence is of&amp;nbsp;value 1 I hold this value for 5 subsequent uses of the formula where&amp;nbsp;what goes into Column-D depends on the aritmetic performed on the contents of Columns B and C. (For example Column-D=Column-B-Value + Column-C-Value.) See the attachment to see in a picture what I mean.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any help would be great and much appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2017 09:22:44 GMT</pubDate>
    <dc:creator>scottahindle</dc:creator>
    <dc:date>2017-06-09T09:22:44Z</dc:date>
    <item>
      <title>Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40163#M23507</link>
      <description>&lt;P&gt;I would like to do something that I learnt a long time ago in VB, but am struggling with JMP scripting language. I am new to JMP.&lt;/P&gt;&lt;P&gt;I would like to run a For loop in a formula but use a cell array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I know I can reference a column as follows: j = Column ("a");&lt;/P&gt;&lt;P&gt;If I then say j[4] = 77 + 2; &amp;nbsp;&amp;nbsp;I will get the value 79 in column “a”, row 4.&lt;/P&gt;&lt;P&gt;What, though, if I wanted to run a loop on Column "a", for example For(i=1,i&amp;lt;=20,i++, &lt;FONT face="arial black,avant garde"&gt;SOME FORMULA USING&lt;/FONT&gt; j[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the attachment I would like to use column-B Row [1] with column-C’s Rows 1 to 5. And then, column-B Row [6] with column-C’s Rows 6 to 10. My aim is to use the sequence in Column-A as an identifier, hence each time the sequence is of&amp;nbsp;value 1 I hold this value for 5 subsequent uses of the formula where&amp;nbsp;what goes into Column-D depends on the aritmetic performed on the contents of Columns B and C. (For example Column-D=Column-B-Value + Column-C-Value.) See the attachment to see in a picture what I mean.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any help would be great and much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 09:22:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40163#M23507</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2017-06-09T09:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40165#M23509</link>
      <description>&lt;P&gt;The following formula works for your attached example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;targetrow = (Row() - :Name( "Column-A" )) + 1;
:Name( "Column-B" )[targetrow] + :Name( "Column-C" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember, the formula will always loop through all of the rows, and the function, Row(), will always give you the row that is currently being worked on. &amp;nbsp;When using a formula in JMP, one needs to look at what results are needed when looking at a given row. &amp;nbsp;It is a different paradigm&amp;nbsp;than VB&lt;/P&gt;
&lt;P&gt;Here is another version, doing the For looping you are looking for&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( :Name( "Column-A" ) == 5,
	For( i = Row() - 4, i &amp;lt;= Row(), i++,
		:Name( "Column-D" )[i] = :Name( "Column-B" )[Row() - 4] + :Name( "Column-C" )[i]
	)
);
// The last value calculated will be the value for the current row, 
// so it needs to be handled as a special case
:Name( "Column-B" )[Row() - 4] + :Name( "Column-C" )[Row()];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I guess that technically, you could approximate a VB world, if one bypassed all processing for all of the rows, until the last row was detected, and then you could go back and loop through all of the rows under program control.....that seems like a lot of work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=current data table();
If(Row()==N Rows(dt),
&amp;lt;Do whatever processing you want&amp;gt;
);
&amp;lt;Process for the current(last) row&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 10:29:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40165#M23509</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-09T10:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40200#M23523</link>
      <description>&lt;P&gt;&lt;FONT color="#0000dd" face="Courier New" size="2"&gt;I am using this script to color in yellow a cell if last 30 days average&amp;nbsp;is more then +1 sigma compare to target &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000dd" face="Courier New" size="2"&gt;For&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; i &lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;=&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i &lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&amp;lt;=&lt;/FONT&gt; &lt;FONT color="#0000dd" face="Courier New" size="2"&gt;N Row&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; dt &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;++,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000dd" face="Courier New" size="2"&gt;If&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000dd" face="Courier New" size="2"&gt;Column&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; dt&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"Mean 30 days"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;)[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt; &lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;((&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#0000dd" face="Courier New" size="2"&gt;Column&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; dt&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"Target"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;)[&lt;/STRONG&gt;i&lt;STRONG&gt;])&lt;/STRONG&gt; &lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;+&lt;/FONT&gt; &lt;FONT color="#0000dd" face="Courier New" size="2"&gt;Column&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; dt&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"Std"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;)[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000dd" face="Courier New" size="2"&gt;Column&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; dt&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"Mean 30 days"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&amp;lt;&amp;lt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Color Cells&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;9&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;{&lt;/STRONG&gt;i&lt;STRONG&gt;}&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:09:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40200#M23523</guid>
      <dc:creator>guy_yosef</dc:creator>
      <dc:date>2017-06-09T15:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40201#M23524</link>
      <description>&lt;P&gt;Is there a question?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:14:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40201#M23524</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-09T15:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40399#M23669</link>
      <description>&lt;P&gt;Thank you, Jim!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 07:27:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40399#M23669</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2017-06-14T07:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using specific row values for use in a formula with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40400#M23670</link>
      <description>&lt;P&gt;In the end it took me a while to work out the way JMP scripting works. The attachments show what I have done, which works for me. (The example deviates from the simple example I used to start this discussion.)&lt;/P&gt;&lt;P&gt;If anybody has any tips on how to approach this kind of problem differently please comment. Having used for loops and if conditions in basic VB programming for so many years, and being new to JMP, means I may need guidance on better understanding how to approach JMP scripting.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 07:30:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-specific-row-values-for-use-in-a-formula-with-JSL/m-p/40400#M23670</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2017-06-14T07:30:28Z</dc:date>
    </item>
  </channel>
</rss>

