<?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: Using loops in formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326359#M57564</link>
    <description>&lt;P&gt;I do think your current understanding of formula usage is in error.&amp;nbsp; I am particularly confused with what your&amp;nbsp; expected results for the formula&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i=0, i&amp;lt;=5, i++, :Strain )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;By default, formulas are run once for each row.&amp;nbsp; Therefore, most of the time a For() loop would not be used.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp; have attached a data table with 4 different formulas applied.&amp;nbsp; I am hoping that if you look at the different formulas, that it will help you adjust your understanding of how formulas work.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Oct 2020 18:14:48 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-10-25T18:14:48Z</dc:date>
    <item>
      <title>Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/39102#M22865</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use loop in the column formula? For example, I have a column named &amp;nbsp;TEST, and I write for (i=1, i&amp;lt;5, i++, :TEST=char(i)) ... but I do not get anything, that column is blank after I&amp;nbsp;hit apply/OK. From the loop I am hoping to get every&amp;nbsp;row in the column would be 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for asking such a simple question, but coluldn't find the answer by&amp;nbsp;quickly going thru appendix A of "Using JMP" manual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Ahmad&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 00:16:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/39102#M22865</guid>
      <dc:creator>aumair</dc:creator>
      <dc:date>2017-05-11T00:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/39103#M22866</link>
      <description>&lt;P&gt;No need to reply....found out the issue, thanks! Assignment should be outside the loop.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 00:30:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/39103#M22866</guid>
      <dc:creator>aumair</dc:creator>
      <dc:date>2017-05-11T00:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326243#M57541</link>
      <description>&lt;P&gt;Hi, I am trying to use loops in the column formula for the first time, and I seem to be running into your original problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you clarify how you solved the issue, and what you meant by the assignment should be outside the loop?&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Oct 2020 19:43:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326243#M57541</guid>
      <dc:creator>gronk</dc:creator>
      <dc:date>2020-10-24T19:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326269#M57549</link>
      <description>&lt;P&gt;What is your specific issue.&amp;nbsp; Can you post what formula you are currently using that isn't working for you?&lt;/P&gt;</description>
      <pubDate>Sat, 24 Oct 2020 20:45:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326269#M57549</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-24T20:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326330#M57555</link>
      <description>&lt;P&gt;Thank you very much for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final problem I'm trying to solve is the following: I have stress-strain data for multiple test strips for multiple formulations (&lt;FONT color="#0000FF"&gt;please see the attached JMP data file&lt;/FONT&gt;). The attached table contains 4 different formulation+strip "groups" i.e) FormA/strip1, FormA/strip2, FormB/strip1, FormB/strip2... For each group, I need to identify 1) the maximum stress (tensile strength) and 2) the strain associated with the maximum stress. To identify the maximum stress, I created a column "Tensile Strength" and used simply used "Col Max()" in the Formula Editor (see image below)&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gronk_1-1603595768574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/27648i3FC9B46901B894B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gronk_1-1603595768574.png" alt="gronk_1-1603595768574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Now, I'm looking to populate the "%elongation" column with the strain values associated with the maximum stress (tensile strength) for each group, and this is where my issue lies&lt;/FONT&gt;.&amp;nbsp;&lt;STRONG&gt;Rather than going through the table to manually identify these strain values and populate the "%elongation" column, I'm wondering if there's a way to accomplish this with a column formula (or JSL script)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I was thinking this may involve a combination of loops and/or conditional functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially, I experimented with iterating through the "Stress" column with a for loop, to check if Stress=Tensile Strength in a given row (if yes, then populate the "%elongation" column with the associated strain value). Please see the attached JPG file "stress-strain data_jmp community help_iteration attempt" for the initial column formula/attempt. The column remained unchanged/blank.&lt;/P&gt;&lt;P&gt;I then tried to simply populate the first 5 rows in the "%elongation" column with the strain values in the given rows (please see the attached JPG file "stress-strain data_jmp community help_for loop"). The column remained blank,&amp;nbsp;and this is what prompted my initial post. I'm assuming there are key errors in how I'm using the functions.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;**Moreover, I recognize that my initial formula is far too simplistic for my final goal.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the lengthy post and if I was unclear with anything. I'd be happy to provide any clarification. I'm quite new to JMP, thus any advice/help with this would be greatly appreciated. Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2020 06:07:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326330#M57555</guid>
      <dc:creator>gronk</dc:creator>
      <dc:date>2020-10-25T06:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326331#M57556</link>
      <description>&lt;P&gt;Here is a formula for the creation of %elongation.&amp;nbsp; It is not a very efficient formula, but it will find the value regardless of the order of the data.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;curForm = :Formulation;
curStrip = :Strip;
theRow = (Current Data Table() &amp;lt;&amp;lt; get rows where(
	:Formulation == curForm &amp;amp; :Strip == curStrip &amp;amp; :Stress == :Tensile Strength
))[1];
:Strain[theRow];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the data are sorted by Formulation and Strip, then the more efficient formula below can be used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1 | :Formulation != Lag( :Formulation ) | :Strip != Lag( :Strip ),
	curForm = :Formulation;
	curStrip = :Strip;
	theRow = (Current Data Table() &amp;lt;&amp;lt; get rows where(
		:Formulation == curForm &amp;amp; :Strip == curStrip &amp;amp; :Stress == :Tensile Strength
	))[1];
);
:Strain[theRow];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Oct 2020 08:46:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326331#M57556</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-25T08:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326356#M57561</link>
      <description>&lt;P&gt;Thanks so much for your help/response.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In regards to the simple for loop I used to try to populate the first five rows in the "%elongation" column, I'm curious why the column remains unchanged/blank. Am I completely off the mark in how I used the formula and/or defined the arguments?&lt;/P&gt;&lt;P&gt;In the very early stages of learning JMP and JSL, trying to learn from my mistakes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the help!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2020 17:27:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326356#M57561</guid>
      <dc:creator>gronk</dc:creator>
      <dc:date>2020-10-25T17:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using loops in formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326359#M57564</link>
      <description>&lt;P&gt;I do think your current understanding of formula usage is in error.&amp;nbsp; I am particularly confused with what your&amp;nbsp; expected results for the formula&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i=0, i&amp;lt;=5, i++, :Strain )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;By default, formulas are run once for each row.&amp;nbsp; Therefore, most of the time a For() loop would not be used.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp; have attached a data table with 4 different formulas applied.&amp;nbsp; I am hoping that if you look at the different formulas, that it will help you adjust your understanding of how formulas work.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Oct 2020 18:14:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-loops-in-formula/m-p/326359#M57564</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-25T18:14:48Z</dc:date>
    </item>
  </channel>
</rss>

