<?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 Help with Incrementing in Formula Editor in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408171#M65807</link>
    <description>&lt;P&gt;First of all... I'm very new to scripting and right now I'm working in the formula editor. I am trying to do something I thought would be fairly simple...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two columns of data. The first column has status values that are the same for a period of time and then will change and again be constant for a period of time. For example...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second column I would like to increment a number whenever the status changes. So in the example above, the OFFs would be 1, the ONs would be 2, the next set of OFFs would be 3, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I am setting up a conditional statement something like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If&lt;/SPAN&gt;( :C1 Status[&lt;SPAN&gt;Row&lt;/SPAN&gt;()] == :C1 Status[&lt;SPAN&gt;Row&lt;/SPAN&gt;() + &lt;SPAN&gt;1&lt;/SPAN&gt;],&lt;/P&gt;&lt;P&gt;:x,&lt;/P&gt;&lt;P&gt;:x = :x + &lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where C1 Status is the OFF/ON row. I set up x as a Table Variable initially equal to 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm getting some kind of cycle warning and it's not incrementing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:35:00 GMT</pubDate>
    <dc:creator>scott1588</dc:creator>
    <dc:date>2023-06-10T23:35:00Z</dc:date>
    <item>
      <title>Help with Incrementing in Formula Editor</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408171#M65807</link>
      <description>&lt;P&gt;First of all... I'm very new to scripting and right now I'm working in the formula editor. I am trying to do something I thought would be fairly simple...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two columns of data. The first column has status values that are the same for a period of time and then will change and again be constant for a period of time. For example...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;OFF&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;ON&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second column I would like to increment a number whenever the status changes. So in the example above, the OFFs would be 1, the ONs would be 2, the next set of OFFs would be 3, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I am setting up a conditional statement something like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If&lt;/SPAN&gt;( :C1 Status[&lt;SPAN&gt;Row&lt;/SPAN&gt;()] == :C1 Status[&lt;SPAN&gt;Row&lt;/SPAN&gt;() + &lt;SPAN&gt;1&lt;/SPAN&gt;],&lt;/P&gt;&lt;P&gt;:x,&lt;/P&gt;&lt;P&gt;:x = :x + &lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where C1 Status is the OFF/ON row. I set up x as a Table Variable initially equal to 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm getting some kind of cycle warning and it's not incrementing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:35:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408171#M65807</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2023-06-10T23:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Incrementing in Formula Editor</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408190#M65808</link>
      <description>&lt;P&gt;Hi Scott,&lt;/P&gt;
&lt;P&gt;I tend to use the LAG function for this type of operation as shown below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	1,
	If( :C1== Lag( :C1, 1 ),
		Lag( :PERIOD, 1 ),
		Lag( :PERIOD, 1 ) + 1
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is not as elegant but it is reliable.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 20:34:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408190#M65808</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-08-09T20:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Incrementing in Formula Editor</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408192#M65809</link>
      <description>&lt;P&gt;Brilliant! Worked like a charm. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 21:05:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-Incrementing-in-Formula-Editor/m-p/408192#M65809</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2021-08-09T21:05:06Z</dc:date>
    </item>
  </channel>
</rss>

