<?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: Col Cumulative Sum without calling the current row's value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747478#M92761</link>
    <description>&lt;P&gt;Hello, I've been learning a lot about writing JSL scripts through the forum and watching lecture videos. I have a follow-up question regarding the following script. I got the same results with the second line. May I know why you would choose the first line over the second one?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval( Eval Expr( casesMatrix = Expr( :cases[i - 1] ) ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;LI-CODE lang="markup"&gt;Eval( casesMatrix = :cases[i - 1]  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Additionally, is there a way to avoid modifying the column "R" and keeping the original values? I want the modified R values to remain inside the column "Cases" without appearing anywhere. I tried assigning a different variable name, "Rx", to the modified R as below. However, this approach requires me to create an empty column named "Rx" to work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:Rx [i] = :R[i] * (1 - (Sum( casesMatrix )+casesSum) * 4 / 100);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks in advance for your time and expertise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 13:30:31 GMT</pubDate>
    <dc:creator>tMinnx</dc:creator>
    <dc:date>2024-04-17T13:30:31Z</dc:date>
    <item>
      <title>Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739077#M92035</link>
      <description>&lt;P&gt;Hello, I am quite new to writing JMP scripts and primarily use "Edit Formula" for my work. I have been browsing solutions related to &lt;STRONG&gt;Col Cumulative Sum&lt;/STRONG&gt; and could not find one for my specific problem. The simplified version of my data table is as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Row&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Col Cumulative Sum&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;My Wish&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula below works if the current row value of "Week" is fixed or if I have two separate columns "Week" and "My Wish."&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;If( Row() != 1,
	Lag( Col Cumulative Sum( :Week ), 1 ),
	0
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that the value of the previous row's "Week" is fixed but the current row's is not. And I only have one column "Week" to work with. I am developing a formula that simulates progression based on the previous simulation value.&amp;nbsp;I am simulating the current row's "Week" value based on the previous row's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I am working on Row 4 in the column "Week." I want to cumulatively sum all the previous "Week" values without calling the current "Week" value in the function. Otherwise, it creates an illegal reference or cycling problem in my case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using subscript instead of lag since the lag function calls the current row's "Week" value. It did not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() != 1,
	Col Cumulative Sum( :Week )[Row() - 1],
	0
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I hope my explanation was clear enough. Thank you for your time and expertise in advance. I use JMP Pro 17.&lt;/P&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>Tue, 26 Mar 2024 09:31:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739077#M92035</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-26T09:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739084#M92036</link>
      <description>&lt;P&gt;You can deduct current weeks value from the cumulative sum&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Cumulative Sum(:Week) - :Week&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-1711447034404.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62678iFFD58FB05EAEE2D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1711447034404.png" alt="jthi_0-1711447034404.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 09:57:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739084#M92036</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-26T09:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739085#M92037</link>
      <description>&lt;P&gt;The moment I use (:Week) in my formula I get an illegal reference problem. The current row (:Week) has not been fully calculated yet. I can only recall (:Week) from the previous row in theory.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 10:03:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739085#M92037</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-26T10:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739086#M92038</link>
      <description>&lt;P&gt;If I am understanding correctly, I think this might be the solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() != 1,
	Sum( :Week[Index( 1, Row() - 1 )] ),
	0
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Mar 2024 10:15:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739086#M92038</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-26T10:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739088#M92040</link>
      <description>&lt;P&gt;I would use separate columns to avoid all sorts of issues, but I'm not exactly sure what you are trying to achieve as you have full data in your example. Maybe something like this if Col Cumulative Sum doesn't work for you (calculate value using Lag and variable)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1,
	val = 0,
	val = val + Lag(:Week);
);
val;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 10:22:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739088#M92040</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-26T10:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739092#M92042</link>
      <description>&lt;P&gt;Thank you for your suggestion on using the &lt;FONT color="#3366FF"&gt;Index&amp;nbsp;&lt;/FONT&gt;subscript. I now encounter the issue "object not subscriptable."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My &lt;EM&gt;week&lt;/EM&gt; example was over-simplified and I have a matrix &lt;EM&gt;Sim Cases&lt;/EM&gt;&amp;nbsp;of 4 rows and 1 column in place of &lt;EM&gt;week&lt;/EM&gt;. To transform it into one summarized numerical value, I multiplied the matrix with [1 1 1 1] and added a subscript [&lt;FONT color="#339966"&gt;1&lt;/FONT&gt;]. It was then followed by the &lt;FONT color="#3366FF"&gt;Index&lt;/FONT&gt; subscript.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Sum( ([1 1 1 1] * :Sim Cases)[1][Index( 1, Row() - 1 )] )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think the resulting numerical value from the original 4x1 matrix is not accepting any subscript after&amp;nbsp;[&lt;FONT color="#339966"&gt;1&lt;/FONT&gt;]. Or it could be because of the illegal reference (recursion) again.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 10:56:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739092#M92042</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-26T10:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739096#M92044</link>
      <description>&lt;P&gt;Yes, at first, I tried to emulate in the JMP data table what I usually do in Excel spreadsheets by separating columns. I would then call the values of the previous row of a different column.&amp;nbsp;The JMP data table does not behave as Excel spreadsheets, and I am encountering cyclical problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I keep changing strategies and my current understanding is to keep every required variable in one column to avoid cyclical problems.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 11:08:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739096#M92044</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-26T11:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739100#M92045</link>
      <description>&lt;P&gt;Is "Sim Cases" a matrix or a column in a data table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not understand&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You appear to be making your solution overly complex.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sim cases = [3,5,2,8];

sum1 = sum(sim cases);
sum2 = sum(([1 1 1 1]*sim cases)[1]);
show(sum1,sum2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both sum1 and sum2 provide the same value&lt;/P&gt;
&lt;PRE&gt;sum1 = 18;
sum2 = 18;&lt;/PRE&gt;
&lt;P&gt;I encourage you to read the Discovering JMP document available under the Help pull down menu.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 11:25:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739100#M92045</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-26T11:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739101#M92046</link>
      <description>&lt;P&gt;I will keep learning JMP. For now, I will just stick to my Excel spreadsheet. Thanks everyone for your responses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sim Cases&amp;nbsp;&lt;/EM&gt;is a column and I am using &lt;EM&gt;Sim Cases&lt;/EM&gt; of previous rows in creating new rows. So I guess it is both a column and a variable inside that same column.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 11:31:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739101#M92046</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-26T11:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739105#M92048</link>
      <description>&lt;P&gt;How JMP tables and spreadsheets behave are totally different and this old post might be a good read &lt;LI-MESSAGE title="JMP is Not a Spreadsheet" uid="214307" url="https://community.jmp.com/t5/Discussions/JMP-is-Not-a-Spreadsheet/m-p/214307#U214307" 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;as it provides some examples and explanation. You can do most of the stuff in JMP but it can take some time to get your head around how columns+rows behave in JMP vs single cell in excel.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 11:36:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739105#M92048</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-26T11:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739262#M92083</link>
      <description>&lt;P&gt;Hello again. I am rephrasing my question in the hope that I can make the frustration go away.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Row&lt;/TD&gt;&lt;TD&gt;R&lt;/TD&gt;&lt;TD&gt;Cases&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;[1, 1, 2, 1]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1.67&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2.3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 columns, &lt;STRONG&gt;&lt;EM&gt;R&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;Cases&lt;/EM&gt;&lt;/STRONG&gt;. &lt;EM&gt;Cases&lt;/EM&gt;&amp;nbsp;are calculated by multiplying &lt;EM&gt;&lt;STRONG&gt;R&lt;/STRONG&gt;&lt;/EM&gt; from the current row with &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt;&lt;/EM&gt; from the previous row. In addition, &lt;EM&gt;&lt;STRONG&gt;R&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;needs to be modified (reduced) based on the sum of &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt;&lt;/EM&gt; from the previous row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;R&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;(row2) in column &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt; &lt;/EM&gt;= &lt;EM&gt;&lt;STRONG&gt;R&lt;/STRONG&gt; &lt;/EM&gt;(row2) * modifier&lt;/P&gt;&lt;P&gt;modifier = 1 - &lt;FONT color="#000000"&gt;(&lt;/FONT&gt;&lt;FONT color="#00FF00"&gt;&lt;FONT color="#000000"&gt;(&lt;/FONT&gt;&lt;FONT color="#339966"&gt;&lt;U&gt;cumulative&amp;nbsp;&lt;/U&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#339966"&gt;&lt;U&gt;sum of &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt; &lt;/EM&gt;from row1 to the row before the current row&lt;/U&gt;&lt;/FONT&gt; * &lt;FONT color="#FF0000"&gt;4&lt;/FONT&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;/&lt;FONT color="#FF0000"&gt;Total Population&lt;/FONT&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Total Population is a parameter and is 100.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The resulting modifier&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;is multiplied with &lt;STRONG&gt;&lt;EM&gt;Cases&lt;/EM&gt;&lt;/STRONG&gt; from row1 to create &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt;&lt;/EM&gt; in row2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, I am expecting the modified&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;R&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;(row2)&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;to be 1.12 and &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt; &lt;/EM&gt;(row2) to be [1.12, 1.12, 2.24, 1.12]&lt;/P&gt;&lt;P&gt;1.4 * 1 - (&lt;FONT color="#339966"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt; * &lt;FONT color="#FF0000"&gt;4&lt;/FONT&gt;/&lt;FONT color="#FF0000"&gt;100&lt;/FONT&gt;) = 1.12&lt;/P&gt;&lt;P&gt;1.12 * [1, 1, 2, 1] =&amp;nbsp;[1.12, 1.12, 2.24, 1.12]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I expect the modified &lt;EM&gt;&lt;STRONG&gt;R&lt;/STRONG&gt;&lt;/EM&gt; (row3) to be 0.71 and &lt;EM&gt;&lt;STRONG&gt;Cases&lt;/STRONG&gt; &lt;/EM&gt;(row3) to be [0.8, 0.8, 1.6, 0.8]&lt;/P&gt;&lt;P&gt;1.67 * 1 - (&lt;FONT color="#339966"&gt;&lt;STRONG&gt;10.6&lt;/STRONG&gt;&lt;/FONT&gt; * &lt;FONT color="#FF0000"&gt;4&lt;/FONT&gt;/&lt;FONT color="#FF0000"&gt;100&lt;/FONT&gt;) = 0.71&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;10.6&lt;/STRONG&gt;&lt;/FONT&gt; is from &lt;FONT color="#000000"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt; cases in row1 and &lt;STRONG&gt;5.6&lt;/STRONG&gt; cases in row2.&lt;/P&gt;&lt;P&gt;0.71 *&amp;nbsp;[1.12, 1.12, 2.24, 1.12] = [0.8, 0.8, 1.6, 0.8]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a problem in getting the &lt;STRONG&gt;&lt;FONT color="#339966"&gt;green&lt;/FONT&gt;&lt;/STRONG&gt; value. My current attempt at writing a JMP script is as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	Matrix( {1, 1, 2, 1} ),
	:R * (1 - (Summation( i = 1, N Row() - 1, Sum( :Cases ) ) * 4) / Total Population) * Lag( :Cases, 1 )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried &lt;FONT color="#0000FF"&gt;Index&lt;/FONT&gt;, &lt;FONT color="#0000FF"&gt;Lag&lt;/FONT&gt;, &lt;FONT color="#0000FF"&gt;Row() - 1&lt;/FONT&gt;, &lt;FONT color="#0000FF"&gt;Col cumulative sum&lt;/FONT&gt;, &lt;FONT color="#0000FF"&gt;Summation&lt;/FONT&gt;, etc to get the modifier, and nothing has worked. I mainly get either&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) illegal referencing or&lt;/P&gt;&lt;P&gt;2) unsubscriptable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for your time and expertise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 05:48:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739262#M92083</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-27T05:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739315#M92100</link>
      <description>&lt;P&gt;Here is my solution, however, it does not match your solution.&amp;nbsp; I believe your calculations as shown are incorrect for Row 3. See my script, which includes your sample data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Example",
	Add Rows( 4 ),
	New Column( "R",
		Numeric,
		"Continuous",
		Set Values( [., 1.4, 1.67, 2.3] )
	),
	New Column( "Cases",
		Expression,
		"None",
		Set Values( {[1, 1, 2, 1], Empty(), Empty(), Empty()} )
	)
);

// The calculation script
casesSum = 0;
For(i=2,i&amp;lt;=nrows(dt),i++,
		Eval( Eval Expr( casesMatrix = Expr( :cases[i - 1] ) ) );
		:R[i] = :R[i] * (1 - (Sum( casesMatrix )+casesSum) * 4 / 100);
		:Cases[i] = casesMatrix * :R[i];
		casesSum = casesSum + sum(casesMatrix);
);


// Row 3 R does not seem to be correct
// I can not come up with .71, I come up with .96192
show(1.4 * (1 - (5 * 4/100)) ); 
show(1.67 * (1 - (10.6 * 4/100)) ); 



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1711546109146.png" style="width: 839px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62726iC3EF6C5210F87042/image-dimensions/839x263?v=v2" width="839" height="263" role="button" title="txnelson_0-1711546109146.png" alt="txnelson_0-1711546109146.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 13:28:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739315#M92100</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-27T13:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739418#M92126</link>
      <description>&lt;P&gt;Thank you very much. The &lt;FONT color="#3366FF"&gt;for&lt;/FONT&gt; loop seems to be the key here. I have yet to learn the functions,&amp;nbsp;&lt;FONT color="#3366FF"&gt;Eval&lt;/FONT&gt;, &lt;FONT color="#3366FF"&gt;Eval Expr&lt;/FONT&gt;, and &lt;FONT color="#3366FF"&gt;Expr&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you are right, my calculations in the example were off.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 06:24:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/739418#M92126</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-03-28T06:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747478#M92761</link>
      <description>&lt;P&gt;Hello, I've been learning a lot about writing JSL scripts through the forum and watching lecture videos. I have a follow-up question regarding the following script. I got the same results with the second line. May I know why you would choose the first line over the second one?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval( Eval Expr( casesMatrix = Expr( :cases[i - 1] ) ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;LI-CODE lang="markup"&gt;Eval( casesMatrix = :cases[i - 1]  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Additionally, is there a way to avoid modifying the column "R" and keeping the original values? I want the modified R values to remain inside the column "Cases" without appearing anywhere. I tried assigning a different variable name, "Rx", to the modified R as below. However, this approach requires me to create an empty column named "Rx" to work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:Rx [i] = :R[i] * (1 - (Sum( casesMatrix )+casesSum) * 4 / 100);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks in advance for your time and expertise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 13:30:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747478#M92761</guid>
      <dc:creator>tMinnx</dc:creator>
      <dc:date>2024-04-17T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747595#M92767</link>
      <description>&lt;P&gt;You suggested 2nd line is great.&amp;nbsp; My reason for using the syntax I used is just an old habit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way that Rx can be used without creating an empty column, is to use it as a memory variable reference.&amp;nbsp; Here is the code to do that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// The calculation script
casesSum = 0;
For(i=2,i&amp;lt;=nrows(dt),i++,
		Eval(  casesMatrix = Expr( :cases[i - 1] ) );
		Rx = :R[i] * (1 - (Sum( casesMatrix )+casesSum) * 4 / 100);
		:Cases[i] = casesMatrix * Rx;
		casesSum = casesSum + sum(casesMatrix);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2024 16:09:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747595#M92767</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-04-17T16:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Col Cumulative Sum without calling the current row's value</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747602#M92769</link>
      <description>&lt;P&gt;This script uses txnelson's solution as the starting point and makes some modifications to it. Purpose of this script is just to provide you other example for learning purposes using other techniques (For Each Row instead of For loop, gets values to matrix from :R and some other changes)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = New Table("Example",
	Add Rows(4),
	New Column("R", Numeric, "Continuous", Set Values([., 1.4, 1.67, 2.3])),
	New Column("Cases", Expression, "None", Set Values({[1, 1, 2, 1], Empty(), Empty(), Empty()}))
);

r_m = :R &amp;lt;&amp;lt; Get values;
casesSum = 0;
For Each Row(dt,
	If(Row() == 1, Continue()); // skip first row
	
	casesMatrix = Lag(:cases, 1);
	r_m[Row()] = r_m[Row()] * (1 - (Sum(casesMatrix) + casesSum) * 4 / 100);
	:Cases = casesMatrix * r_m[Row()];
	casesSum = casesSum + Sum(casesMatrix);
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2024 16:43:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Cumulative-Sum-without-calling-the-current-row-s-value/m-p/747602#M92769</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-17T16:43:35Z</dc:date>
    </item>
  </channel>
</rss>

