<?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 Getting a Cumulative Sum Count based on multiple column conditions in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720204#M90240</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to incrementally count rows in a dataset based on matching conditions in three other columns. Essentially if the rows in Column A, B, and C match, then Column D = 1; when Column C changes (Depth) but Column A and B stay the same, Column D = 2. I need this count to restart from one when Column A (Site ID) &lt;STRONG&gt;or&lt;/STRONG&gt; B (Year) change. I have gotten this far with the following formula:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum( 1, :Site Code, :Year, :Depth )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gives me the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PivotalWeasel30_3-1706633956877.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60750iAA9C37C7B5C20D99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PivotalWeasel30_3-1706633956877.png" alt="PivotalWeasel30_3-1706633956877.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;Which is close, but I need Column D (Sample #)&amp;nbsp;to look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PivotalWeasel30_2-1706633852754.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60749i91D7C7BEB52FBE25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PivotalWeasel30_2-1706633852754.png" alt="PivotalWeasel30_2-1706633852754.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies if my explanation is unclear, but hopefully the pictures clarify what I mean.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2024 17:03:15 GMT</pubDate>
    <dc:creator>PivotalWeasel30</dc:creator>
    <dc:date>2024-01-30T17:03:15Z</dc:date>
    <item>
      <title>Getting a Cumulative Sum Count based on multiple column conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720204#M90240</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to incrementally count rows in a dataset based on matching conditions in three other columns. Essentially if the rows in Column A, B, and C match, then Column D = 1; when Column C changes (Depth) but Column A and B stay the same, Column D = 2. I need this count to restart from one when Column A (Site ID) &lt;STRONG&gt;or&lt;/STRONG&gt; B (Year) change. I have gotten this far with the following formula:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum( 1, :Site Code, :Year, :Depth )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gives me the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PivotalWeasel30_3-1706633956877.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60750iAA9C37C7B5C20D99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PivotalWeasel30_3-1706633956877.png" alt="PivotalWeasel30_3-1706633956877.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;Which is close, but I need Column D (Sample #)&amp;nbsp;to look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PivotalWeasel30_2-1706633852754.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60749i91D7C7BEB52FBE25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PivotalWeasel30_2-1706633852754.png" alt="PivotalWeasel30_2-1706633852754.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies if my explanation is unclear, but hopefully the pictures clarify what I mean.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 17:03:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720204#M90240</guid>
      <dc:creator>PivotalWeasel30</dc:creator>
      <dc:date>2024-01-30T17:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a Cumulative Sum Count based on multiple column conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720214#M90241</link>
      <description>&lt;P&gt;P.S. I know the images are from Excel, I just exported a subset of my data for clarity.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 17:04:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720214#M90241</guid>
      <dc:creator>PivotalWeasel30</dc:creator>
      <dc:date>2024-01-30T17:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a Cumulative Sum Count based on multiple column conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720226#M90242</link>
      <description>&lt;P&gt;You could combine Col Cumulative Sum with Col Min&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(12),
	Compress File When Saved(1),
	New Column("Column 1", Character, "Nominal", Set Values({"A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B"})),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 2, 3, 1, 1, 1, 1, 2, 2, 3, 3]))
);

dt &amp;lt;&amp;lt; New Column("R", Numeric, Continuous, Formula(
	Col Cumulative Sum(Row() == Col Min(Row(), :Column 1, :Column 2, :Column 3), :Column 1, :Column 2)
));&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-1706634475143.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60751iA6E8AFF4C5DD8831/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1706634475143.png" alt="jthi_0-1706634475143.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 17:08:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Getting-a-Cumulative-Sum-Count-based-on-multiple-column/m-p/720226#M90242</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-01-30T17:08:43Z</dc:date>
    </item>
  </channel>
</rss>

