<?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: JMP script to create sequence column based on group from another source column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397836#M64854</link>
    <description>&lt;P&gt;As &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt; said there are lots of solutions in the community for similar problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use Lag(), but also Col formulas can be helpful in cases like these:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(1, :Cycle)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you need to shift it by 1 you can add -1 to the formula after Col Cumulative Sum().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not necessarily helpful in this particular case, but very helpful video by &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt; which will most likely be useful at some point:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-On-Air/Special-Formula-Columns/ta-p/257371" target="_blank" rel="noopener"&gt;Special Formula Columns&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jul 2021 07:32:16 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-07-02T07:32:16Z</dc:date>
    <item>
      <title>JMP script to create sequence column based on group from another source column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397810#M64851</link>
      <description>&lt;P&gt;I have a large data set where the cycle changes over time. I would like to create a column that has an index by 1 at the start of each cycle and continues to count up until the next cycle starts then the counts starts back at 0. I have tried using the count and sequence functions shown below but I run into problems when my second cycle has more values that my first cycle (see diagram below where the cycle observation is the value I want the formula to produce and Column 109 is what is produced by the script.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dt &amp;lt;&amp;lt; New Column("Cycle Observation", Numeric, Formula (If(&lt;BR /&gt;:Cycle == 1, Sequence( 0, 1080, 1 ),&lt;BR /&gt;:Cycle == 2, Sequence( 0, 1439, 1 ),&lt;BR /&gt;:Cycle == 3, Sequence( 0, 360, 1 ),&lt;BR /&gt;:Cycle == 4, Sequence( 0, 360, 1 ),&lt;BR /&gt;:Cycle == 5, Sequence( 0, 360, 1 ),&lt;BR /&gt;:Cycle == 6, Sequence( 0, 180, 1 ),&lt;BR /&gt;:Cycle == 7, Sequence( 0, 180, 1 ),&lt;BR /&gt;:Cycle == 8, Sequence( 0, 180, 1 ),&lt;BR /&gt;:Cycle == 9, Sequence( 0, 180, 1 ),&lt;BR /&gt;:Cycle == 10, Sequence( 0, 180, 1 ),&lt;BR /&gt;Sequence( 0, 180, 1 )&lt;BR /&gt;)));&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thedellette_0-1625195720677.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33946i908223C21372F6F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thedellette_0-1625195720677.png" alt="thedellette_0-1625195720677.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:51:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397810#M64851</guid>
      <dc:creator>thedellette</dc:creator>
      <dc:date>2023-06-09T19:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to create sequence column based on group from another source column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397816#M64852</link>
      <description>&lt;P&gt;There are several previous Discussion entries concerning this topic, but since it is an easy solution, I have created another example for your specific situation.&lt;/P&gt;
&lt;P&gt;Attached is a data table with a formula column that calculates the values desired&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1625198922052.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33947i5BD2F647BCF0AF7C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1625198922052.png" alt="txnelson_0-1625198922052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The formula is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	value = 1,
	If( :Cycle != Lag( :Cycle ),
		value = 1,
		value
		++)
);
value;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;While my solution works fine,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;solution below is a better solution.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 15:40:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397816#M64852</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-07-02T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to create sequence column based on group from another source column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397836#M64854</link>
      <description>&lt;P&gt;As &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt; said there are lots of solutions in the community for similar problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use Lag(), but also Col formulas can be helpful in cases like these:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(1, :Cycle)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you need to shift it by 1 you can add -1 to the formula after Col Cumulative Sum().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not necessarily helpful in this particular case, but very helpful video by &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt; which will most likely be useful at some point:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-On-Air/Special-Formula-Columns/ta-p/257371" target="_blank" rel="noopener"&gt;Special Formula Columns&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 07:32:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397836#M64854</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-07-02T07:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script to create sequence column based on group from another source column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397991#M64871</link>
      <description>Thank you very much this is very helpful information and the Col Cumulative Sum() is a very elegant way to do it.</description>
      <pubDate>Fri, 02 Jul 2021 15:19:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-to-create-sequence-column-based-on-group-from-another/m-p/397991#M64871</guid>
      <dc:creator>thedellette</dc:creator>
      <dc:date>2021-07-02T15:19:06Z</dc:date>
    </item>
  </channel>
</rss>

