<?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: Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868781#M103162</link>
    <description>&lt;P&gt;The 3 If() functions under the first If() function will be run independently from each other.&amp;nbsp; That is, each of them will be evaluated for each row, if the first If() function is True.&lt;/P&gt;
&lt;P&gt;I would use the JSL debugger and step through the code looking for when the value is changing.&amp;nbsp; It will show you where the codes logic is not working the way you want it to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can provide a sample data table, the Community might be able to dig deeper into the problem&lt;/P&gt;</description>
    <pubDate>Wed, 16 Apr 2025 14:46:16 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2025-04-16T14:46:16Z</dc:date>
    <item>
      <title>Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop</title>
      <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868736#M103156</link>
      <description>&lt;P&gt;I have a For Each Row function working on a data table. It goes through a series of If statements evaluating values in some of the columns and then based on the findings it assigns a value to a :Correct_Process column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently I have it setup like this.&lt;/P&gt;
&lt;PRE&gt;For Each Row(
	dt, 
	If( :Module == "M05" &amp;amp; :Measurement == "Conductivity", 
		If(:Actual &amp;gt; m5_cond_hi | :Actual &amp;lt; m5_cond_low,
			:Correct_Process = "Incorrect",
			:Correct_Process = "Correct"
		);
		If( splits_detected == 1 &amp;amp; Contains( col_name_list, "PMC_FreeForm" ),
			If( :PMC_FreeForm == "DI" | Contains(:PMC_FreeForm, "Mod 5 pump off"), 
				If( :Actual != 0,
					:Correct_Process = "Incorrect",
					:Correct_Process = "Correct"
				);
			);
		);
		If( splits_detected == 1 &amp;amp; Contains( col_name_list, "CPMC_Conductivity" ), 
			num_cond = Num(:CPMC_Conductivity);
			lim_hi = num_cond + 0.6;
			lim_low = num_cond - 0.6;
			If( :Actual &amp;gt; lim_hi | :Actual &amp;lt; lim_low,
				show("Evaluated Incorrect");
				:Correct_Process = "Incorrect",
				show("Evaluated Correct");
				:Correct_Process = "Correct"
			);
		);
&lt;/PRE&gt;
&lt;P&gt;When I run the script, if the value of :CPMC_Conductivity is "13.2" and the :Actual is 13.5, the :Correct_Process column is still assigned a value of "Incorrect". Interestingly, the log shows "Evaluated Correct" due to the show() statement when I would expect it to which means the If statements are being evaluated correctly, but the :Correct_Process is not assigned "Correct".&lt;BR /&gt;&lt;BR /&gt;I am assuming its because I am assigning the :Correct_Process column by default with the first nested If statement then trying to overwrite with a more specific check in the third nested if statement. But I have similar checks within this group after this one that seem to be able to successfully overwrite in other conditions (such as the second nested if statement) so I am wondering what I am missing here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 14:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868736#M103156</guid>
      <dc:creator>ShaneLeavens10</dc:creator>
      <dc:date>2025-04-16T14:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop</title>
      <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868747#M103158</link>
      <description>&lt;P&gt;Is there a reason to overwrite same cell value multiple times within the loop?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 14:37:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868747#M103158</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-04-16T14:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop</title>
      <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868780#M103161</link>
      <description>&lt;P&gt;Also, can you provide example dataset? &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quickly checking this works fine&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

For Each Row(dt,
	If(:height &amp;gt; 60,
		Write("\!N", Row(), " 1: If");
		:sex = "A";
	,
		Write("\!N", Row(), " 1: Else");
		:sex = "B";
	);
	If(:weight &amp;gt; 70,
		Write("\!N", Row(), " 2: If");
		:sex = "AA";
	,
		Write("\!N", Row(), " 2: Else");
		:sex = "BB";
	);	
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You also might want to utilize &amp;lt;&amp;lt; Begin Data Update and &amp;lt;&amp;lt; End Data Update &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 14:45:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868780#M103161</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-04-16T14:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop</title>
      <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868781#M103162</link>
      <description>&lt;P&gt;The 3 If() functions under the first If() function will be run independently from each other.&amp;nbsp; That is, each of them will be evaluated for each row, if the first If() function is True.&lt;/P&gt;
&lt;P&gt;I would use the JSL debugger and step through the code looking for when the value is changing.&amp;nbsp; It will show you where the codes logic is not working the way you want it to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can provide a sample data table, the Community might be able to dig deeper into the problem&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 14:46:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868781#M103162</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-04-16T14:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value to cell in For Each Row loop, after its already been assigned a value in the same loop</title>
      <link>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868786#M103164</link>
      <description>&lt;P&gt;No, working from someone else's script and trying to restructure that but was confused how this result was coming about. Your question sparked an idea though and I dug deeper and found this part of the script is working as intended, it was just being overwritten again later on in the script.&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;I used to debugger to locate the third overwrite so thank you for the suggestion!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 15:56:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Assign-value-to-cell-in-For-Each-Row-loop-after-its-already-been/m-p/868786#M103164</guid>
      <dc:creator>ShaneLeavens10</dc:creator>
      <dc:date>2025-04-16T15:56:19Z</dc:date>
    </item>
  </channel>
</rss>

