<?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: How do I count changes in row values? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471373#M71576</link>
    <description>&lt;P&gt;One way would be to create formula using Lag and then you can get max value of that column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	Row() == 1, 
		counter = 1;
	, Lag(:col, 1) != :col, 
		counter++
);
counter;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1647639220121.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40960i3683E856360E0C73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1647639220121.png" alt="jthi_0-1647639220121.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;Maybe something like this could also work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(Lag(:col) != :col)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2022 21:44:25 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-03-18T21:44:25Z</dc:date>
    <item>
      <title>How do I count changes in row values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471332#M71573</link>
      <description>&lt;P&gt;I have a large data set where I have blocks of repeating values like this:&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;I would like to count the number of changes in row values or, in other words, a count of rows ignoring consecutive repeated rows.&amp;nbsp; In this example, the count would be 4 (The third 'A' is a change from 'B', so it counts).&amp;nbsp; Is there a way to have JMP count rows ignoring repeated and consecutive duplicates?&lt;/P&gt;&lt;P&gt;I'm using JMP 15.2.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:46:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471332#M71573</guid>
      <dc:creator>KevinS</dc:creator>
      <dc:date>2023-06-10T23:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count changes in row values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471372#M71575</link>
      <description>&lt;P&gt;Here are a couple of ways to handle this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1647639727269.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40961iDB68EA55E793002C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1647639727269.png" alt="txnelson_0-1647639727269.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	If(
		Row() == 1, count = 1,
		:column 1 != Lag( :column 1 ), count
		++)
);
Show( count );
// Look in the log for the value of count

// or

dt &amp;lt;&amp;lt; New Column( "The Count",
	formula(
		If(
			Row() == 1, count = 1,
			:column 1 != Lag( :column 1 ), count
			++);
			count;
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 21:42:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471372#M71575</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-18T21:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count changes in row values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471373#M71576</link>
      <description>&lt;P&gt;One way would be to create formula using Lag and then you can get max value of that column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
	Row() == 1, 
		counter = 1;
	, Lag(:col, 1) != :col, 
		counter++
);
counter;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1647639220121.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40960i3683E856360E0C73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1647639220121.png" alt="jthi_0-1647639220121.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;Maybe something like this could also work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(Lag(:col) != :col)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 21:44:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471373#M71576</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-18T21:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count changes in row values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471793#M71629</link>
      <description>&lt;P&gt;It seems to be working!&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 20:26:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-count-changes-in-row-values/m-p/471793#M71629</guid>
      <dc:creator>KevinS</dc:creator>
      <dc:date>2022-03-21T20:26:27Z</dc:date>
    </item>
  </channel>
</rss>

