<?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: Cycle Problem in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775399#M95757</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;, and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt; Thank you all for your solutions. I particularly like &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;'s solution. I never knew Col Cumulative Sum could be used that way. Very simple, efficient, and elegant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still trying to wrap my head around how variable work in JMP. I'm not quite sure I have the whole picture yet but I'm working on it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 15:24:58 GMT</pubDate>
    <dc:creator>scott1588</dc:creator>
    <dc:date>2024-07-25T15:24:58Z</dc:date>
    <item>
      <title>Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775266#M95732</link>
      <description>&lt;P&gt;I have this recurring cycle detected problem that I cannot figure out and I'm hoping someone can help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the attached example script. It generates a table. The idea here is I want to label each continuous runs of 1 in Column 1 as an Event with a sequential number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula works. But when I make any modifications to the table or Rerun Formulas I get one, two, or sometimes three cycle detected errors. This is just an example table. On my actual data table, I have had to hit Ignore All Cycles sometimes up to a dozen times if I change a column formula or do other editing on the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what is causing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Cycle Problem",
	Add Rows( 21 ),
	New Table Variable( "P1", 3 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0]
		)
	),
	New Column( "Column 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				Row() == 1, :P1 = 0,
				:Column 1 == 1 &amp;amp; :Column 1[Row() - 1] == 0, :P1 = :P1 + 1,
				:Column 1 == 1, :P1
			)
		),
		Set Selected
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 02:33:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775266#M95732</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-07-25T02:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775287#M95734</link>
      <description>&lt;P&gt;Not sure what the cycle warning means. Looks like a false alarm to me. But meanwhile, I guess the result of following script is what you try to achieve and it does not have the cycle issue.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Cycle Problem",
	Add Rows( 21 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0]
		)
	),
	New Column( "Column 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				Row() == 1, 0,
				:Column 1 == 1 &amp;amp; :Column 1[Row() - 1] == 0, :Column 2[Row() - 1] + 1,
				:Column 2[Row() - 1]
			)
		),
		Set Selected
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 03:30:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775287#M95734</guid>
      <dc:creator>peng_liu</dc:creator>
      <dc:date>2024-07-25T03:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775302#M95738</link>
      <description>&lt;P&gt;Most likely the cycle problems is caused by you setting :P1 table variable value and comparing them in same formula&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1, 
	:P1 = 0
, :Column 1 == 1 &amp;amp; :Column 1[Row() - 1] == 0, 
	:P1 = :P1 + 1
, :Column 1 == 1, 
	:P1
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use formula like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1, 
	retval = 0
, :Column 1 == 1 &amp;amp; Lag(:Column 1) == 0, 
	retval = retval + 1
);
retval;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1721882765352.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66496i531A46F3901930B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1721882765352.png" alt="jthi_1-1721882765352.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/row-functions-2.shtml?os=win&amp;amp;source=application#ww2736368" target="_blank" rel="noopener"&gt;Lag()&lt;/A&gt; gives you access to earlier values in a column&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 04:46:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775302#M95738</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-25T04:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775339#M95744</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is also OK for you to lag the formula column itself. That is, you could use this formula in column C2 for the values you have in C1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	0,
	Lag( :C2 ) + (Lag( :C1 ) == 0 &amp;amp; :C1 == 1)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 12:07:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775339#M95744</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2024-07-25T12:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775353#M95747</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;, and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt;&amp;nbsp;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you assistance on this. The scripts you provided, however, did not quite do what I need to do and when I tried to modify them they didn't work. Specifically, The numbering in Column 2 should only appear when there is a 1 in Column 1. If there is a 0 in Column 1, then Column 2 is blank. Like this...&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="scott1588_0-1721913442677.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66498i7518C6B0D61F73C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="scott1588_0-1721913442677.png" alt="scott1588_0-1721913442677.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to add the additional IF statement to accomplish this, the scripts fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, here is what I did with&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Cycle Problem",
	Add Rows( 21 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0]
		)
	),
	New Column( "Column 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If(
				Row() == 1, 0,
				:Column 1 == 1 &amp;amp; :Column 1[Row() - 1] == 0,
					:Column 2[Row() - 1] + 1,
				:Column 1 == 1, :Column 2[Row() - 1]
			)
		),
		Set Selected
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also noticed another problem that may be related. When I run the original script I provided, Column 2 is blank. However, if I add a Column 3 with any kind of random formula, suddenly the values appear in Column 2. This happens on some of my other tables as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt;&amp;nbsp;I am still working on your solution to see if I can get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the meantime, is there any further guidance you can provide to help me out here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks much for all your help.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 13:23:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775353#M95747</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-07-25T13:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775355#M95748</link>
      <description>&lt;P&gt;You can for example add one If statement to the end&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Cycle Problem",
	Add Rows(21),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0])
	)
);

dt &amp;lt;&amp;lt; new column("C", Numeric, Ordinal, Formula(
	If(Row() == 1,
		retval = 0;
	, :Column 1 == 1 &amp;amp; Lag(:Column 1) == 0,
		retval = retval + 1
	);
	If(:Column 1 == 1,
		retval;
	,
		.
	);
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1721914965578.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66499i5E1771037708C768/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1721914965578.png" alt="jthi_0-1721914965578.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 13:44:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775355#M95748</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-25T13:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775356#M95749</link>
      <description>&lt;P&gt;This seems to work but is cumbersome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	0,
	If( :C1 == 1,
		If( Lag( :C1 ) == 0,
			Max( :C2[Index( 1, Row() - 1 )] ) + 1,
			Lag( :C2 )
		),
		.
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another option, a formula for column "C3":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	Row() == 1,
		c = 0;
		c;
	,
		:C1 == 0, 
		.
	,
		Lag( :C1 ) == 1, 
		Lag( :c3 )
	,
		c++;
		c;
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 13:46:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775356#M95749</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2024-07-25T13:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775357#M95750</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;! That seems to work. Although I'm not sure I understand why it works with a separate IF statement and it doesn't work with a combined IF statement as in my&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;modification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But more importantly, why does creating the table variable cause a problem while creating a variable within the script does not?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 13:51:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775357#M95750</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-07-25T13:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775371#M95751</link>
      <description>&lt;P&gt;Also Col Cumulative Sum() can be used for this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Cycle Problem",
	Add Rows(21),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0])
	)
);

dt &amp;lt;&amp;lt; new column("C", Numeric, Ordinal, Formula(
	If(:Column 1,
		Col Cumulative Sum(Dif(:Column 1) == 1)
	,
		.
	);
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 14:02:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775371#M95751</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-25T14:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775374#M95753</link>
      <description>&lt;P&gt;That's a great one.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 14:44:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775374#M95753</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2024-07-25T14:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775399#M95757</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2781"&gt;@peng_liu&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;, and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt; Thank you all for your solutions. I particularly like &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;'s solution. I never knew Col Cumulative Sum could be used that way. Very simple, efficient, and elegant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still trying to wrap my head around how variable work in JMP. I'm not quite sure I have the whole picture yet but I'm working on it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 15:24:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775399#M95757</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-07-25T15:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cycle Problem</title>
      <link>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775401#M95759</link>
      <description>&lt;P&gt;It can but I'm not 100% sure if you should even though it is one of the better features of JMP Formulas (JMP support told me it is unintended behavior). Here is a wish list item hoping that JMP would acknowledge that it is definitely needed&amp;nbsp;behavior &lt;LI-MESSAGE title="Make using formula expressions in Set Each Value and using expressions as first argument in Col statistical formulas supported behaviour" uid="666966" url="https://community.jmp.com/t5/JMP-Wish-List/Make-using-formula-expressions-in-Set-Each-Value-and-using/m-p/666966#U666966" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the cycle problem and explanation of it, you could contact JMP Support. I could only provide guesses (which might be correct or totally incorrect) as I'm not a JMP developer but I can kinda understand it as it tries to be multiple values at the same time. This might also be a good read&amp;nbsp;&lt;LI-MESSAGE title="I'm Confused About Variables" uid="722542" url="https://community.jmp.com/t5/Discussions/I-m-Confused-About-Variables/m-p/722542#U722542" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 15:53:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Cycle-Problem/m-p/775401#M95759</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-25T15:53:28Z</dc:date>
    </item>
  </channel>
</rss>

