<?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: row operations in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496415#M73429</link>
    <description>&lt;P&gt;If row 1's value for Actual Finish Date is missing, none of the currently proposed scripts will work.&amp;nbsp; Therefore, that issue needs to be handled.&amp;nbsp; The below code, a simple modification to the original JSL will work.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I made a logic error on the original version of the code.&amp;nbsp; I have changed it below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( x = 1, x &amp;lt;= N Rows( dt ), x++,
	If( Is Missing( Column( dt, "Actual Finish Date_" )[x] ),
		If( Row() &amp;gt; 1,
			Column( dt, "bouge pas" )[x] = Column( dt, "Operation Due Date_" )[x] - :Operation Start Date_[x - 1],
			Column( dt, "bouge pas" )[x] = 0; // Set the value if there is not an X-1 row (i.e. row 1)
		),
		Column( dt, "bouge pas" )[x] = Column( dt, "Actual Finish Date_" )[x] - :Actual Execution Start Date_[x]
	);
		
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jun 2022 12:08:58 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-06-01T12:08:58Z</dc:date>
    <item>
      <title>row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496132#M73423</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(x=1,x&amp;lt;=N Rows(dt),x++,
		If(IsMissing(Column(  dt, "Actual Finish Date_" )[x]),
		Column(  dt, "bouge pas" )[x] = Column(  dt, "Operation Due Date_" )[x] - :Operation Start Date_ [x-1],	
		Column(  dt, "bouge pas" )[x] = Column(  dt, "Actual Finish Date_" )[x] - :Actual Execution Start Date_ [x]
		);
		
	);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello, my problem is that I want in the first line of the for, the line x-1 for the column :Operation Start Date_ but this syntax does not work ? Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:00:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/496132#M73423</guid>
      <dc:creator>NetflixCrow956</dc:creator>
      <dc:date>2023-06-09T17:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496210#M73424</link>
      <description>&lt;P&gt;if you are looping over a data table's rows (usually I would try to avoid it and use formula or set each value) I would suggest using For Each Row() instead of For(). Without having example data I would guess that the issue could be that you will get 0 as row number, which isn't valid in JMP (&lt;EM&gt;Invalid Row Number at row 2 in access or evaluation of ':Operation Start Date_[ /*###*/x - 1]' , :Operation Start Date_[/*###*/x - 1]&lt;/EM&gt;)&lt;/P&gt;
&lt;P&gt;Try setting x values manually and seeing what you get, add debug prints and take a look at log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is example script with couple of optional ideas on how you could set bouge pas columns values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(3),
	New Column("Actual Finish Date_", Numeric, "Continuous", Format("Best", 12), Set Values([1, 4, 6])),
	New Column("Actual Execution Start Date_", Numeric, "Continuous", Format("Best", 12), Set Values([0, 2, 3])),
	New Column("Operation Start Date_", Numeric, "Continuous", Format("Best", 12), Set Values([10, 21, 32])),
	New Column("Operation Due Date_", Numeric, "Continuous", Format("Best", 12), Set Values([11, 22, 33])),
	New Column("bouge pas", Numeric, "Continuous")
);

For(x = 1, x &amp;lt;= N Rows(dt), x++,
	If(Is Missing(Column(dt, "Actual Finish Date_")[x]),
		Column(dt, "bouge pas")[x] = Column(dt, "Operation Due Date_")[x] - :Operation Start Date_[x - 1],
		Column(dt, "bouge pas")[x] = Column(dt, "Actual Finish Date_")[x] - :Actual Execution Start Date_[x]
	);
);

/* better option in my opinion
For Each Row(dt,
	If(Is Missing(:"Actual Finish Date_"n),
		:"bouge pas"n = :"Operation Due Date_"n - :Operation Start Date_[Row() - 1],
		"bouge pas"n = :"Actual Finish Date_"n - :Actual Execution Start Date_
	);
);
*/

/* usually best option 
Column(dt, "bouge pas") &amp;lt;&amp;lt; Set Each Value(
	If(Is Missing(:"Actual Finish Date_"n),
		:"Operation Due Date_"n - :Operation Start Date_[Row() - 1],
		:"Actual Finish Date_"n - :Actual Execution Start Date_
	);
);
*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 May 2022 15:22:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/496210#M73424</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-05-31T15:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496415#M73429</link>
      <description>&lt;P&gt;If row 1's value for Actual Finish Date is missing, none of the currently proposed scripts will work.&amp;nbsp; Therefore, that issue needs to be handled.&amp;nbsp; The below code, a simple modification to the original JSL will work.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I made a logic error on the original version of the code.&amp;nbsp; I have changed it below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( x = 1, x &amp;lt;= N Rows( dt ), x++,
	If( Is Missing( Column( dt, "Actual Finish Date_" )[x] ),
		If( Row() &amp;gt; 1,
			Column( dt, "bouge pas" )[x] = Column( dt, "Operation Due Date_" )[x] - :Operation Start Date_[x - 1],
			Column( dt, "bouge pas" )[x] = 0; // Set the value if there is not an X-1 row (i.e. row 1)
		),
		Column( dt, "bouge pas" )[x] = Column( dt, "Actual Finish Date_" )[x] - :Actual Execution Start Date_[x]
	);
		
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 12:08:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/496415#M73429</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-06-01T12:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496946#M73444</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each Row(dt,
	If(Is Missing(:"Actual Finish Date_"n),
		:"bouge pas"n = :"Operation Due Date_"n - :Operation Start Date_[Row() - 1],
		"bouge pas"n = :"Actual Finish Date_"n - :Actual Execution Start Date_
	);
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NetflixCrow956_0-1654083507299.png" style="width: 960px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42840i8368F8D78049D214/image-dimensions/960x120?v=v2" width="960" height="120" role="button" title="NetflixCrow956_0-1654083507299.png" alt="NetflixCrow956_0-1654083507299.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It still doesn't work because from the first line I have empty lines in the column :Actual Finish Date_&amp;nbsp;&amp;nbsp;and I don't know how to do it&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 11:40:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/496946#M73444</guid>
      <dc:creator>NetflixCrow956</dc:creator>
      <dc:date>2022-06-01T11:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/496966#M73445</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NetflixCrow956_0-1654084139990.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42841i9D74BF6EA1AB4234/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NetflixCrow956_0-1654084139990.png" alt="NetflixCrow956_0-1654084139990.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For example for lines 2, 3 4... the result is 6 days when it should be 1 day&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 11:50:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/496966#M73445</guid>
      <dc:creator>NetflixCrow956</dc:creator>
      <dc:date>2022-06-01T11:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: row operations</title>
      <link>https://community.jmp.com/t5/Discussions/row-operations/m-p/503962#M73621</link>
      <description>&lt;P&gt;If the first row has an empty Actual Finish Date_ then your script looks for the previous row, which will not work.&amp;nbsp; You need to replace this line with something that doesn't reference the previous row:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		:"bouge pas"n = :"Operation Due Date_"n - :Operation Start Date_[Row() - 1],&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2022 11:16:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/row-operations/m-p/503962#M73621</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2022-06-09T11:16:34Z</dc:date>
    </item>
  </channel>
</rss>

