<?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 How can you calculate the product of non-empty rows up to the current row? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743382#M92293</link>
    <description>&lt;P&gt;I'm trying to write a column formula that will calculate the product of all of the (non-empty) rows up to the current row.&lt;/P&gt;&lt;P&gt;I've attached an example data table (&amp;amp; screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the "Product" column to be the product of all of the non-empty rows from the "Value" column. I show the manually calculated result and math in the "Desired Result" &amp;amp; "Desired Result Explanation" to the right.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kast_0-1712075899063.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62984iE319F8EC20545144/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kast_0-1712075899063.png" alt="Kast_0-1712075899063.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple data set issues I tried to highlight in the example data table.&lt;/P&gt;&lt;P&gt;1. The number of rows per "Group" will vary between groups.&lt;/P&gt;&lt;P&gt;2. The "Group" will always be together and in order. All group 1 will be together. Group1 will always come before group 2.&lt;/P&gt;&lt;P&gt;3. The Value column will only have one non-empty row per group. It will always be the first row of that group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this might require a "loop" or "for" type of formula, but have limited experience with building these up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if you don't have a solution I appreciate any thoughts or links to guides or other discussions you think might lead me to a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previous Attempts:&lt;BR /&gt;I thought that txnelson's response to this question (&lt;A href="https://community.jmp.com/t5/Discussions/How-to-multiply-all-elements-in-a-list/td-p/667633" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-multiply-all-elements-in-a-list/td-p/667633&lt;/A&gt;) might work but haven't gotten it to give the result I'm looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time and help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JMP Version: 17.2.0, Windows 10&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2024 16:55:14 GMT</pubDate>
    <dc:creator>Kast</dc:creator>
    <dc:date>2024-04-02T16:55:14Z</dc:date>
    <item>
      <title>How can you calculate the product of non-empty rows up to the current row?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743382#M92293</link>
      <description>&lt;P&gt;I'm trying to write a column formula that will calculate the product of all of the (non-empty) rows up to the current row.&lt;/P&gt;&lt;P&gt;I've attached an example data table (&amp;amp; screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the "Product" column to be the product of all of the non-empty rows from the "Value" column. I show the manually calculated result and math in the "Desired Result" &amp;amp; "Desired Result Explanation" to the right.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kast_0-1712075899063.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62984iE319F8EC20545144/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kast_0-1712075899063.png" alt="Kast_0-1712075899063.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple data set issues I tried to highlight in the example data table.&lt;/P&gt;&lt;P&gt;1. The number of rows per "Group" will vary between groups.&lt;/P&gt;&lt;P&gt;2. The "Group" will always be together and in order. All group 1 will be together. Group1 will always come before group 2.&lt;/P&gt;&lt;P&gt;3. The Value column will only have one non-empty row per group. It will always be the first row of that group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this might require a "loop" or "for" type of formula, but have limited experience with building these up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if you don't have a solution I appreciate any thoughts or links to guides or other discussions you think might lead me to a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previous Attempts:&lt;BR /&gt;I thought that txnelson's response to this question (&lt;A href="https://community.jmp.com/t5/Discussions/How-to-multiply-all-elements-in-a-list/td-p/667633" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-multiply-all-elements-in-a-list/td-p/667633&lt;/A&gt;) might work but haven't gotten it to give the result I'm looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time and help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JMP Version: 17.2.0, Windows 10&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 16:55:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743382#M92293</guid>
      <dc:creator>Kast</dc:creator>
      <dc:date>2024-04-02T16:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can you calculate the product of non-empty rows up to the current row?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743404#M92294</link>
      <description>&lt;P&gt;One option using the knowledge that the value is always found from the first row for each group&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1,
	val = 1;
);
If(Row() == Col Min(Row(), :Group),
	val = val * :Value;
,
	.;
);
&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-1712079017042.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62985iA672D255B1AD4108/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1712079017042.png" alt="jthi_0-1712079017042.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;And here is other checking if :Value is missing or not&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(Row() == 1,
	val = 1;
	);
If(!IsMissing(:Value),
	val = val * :Value;
,
	.
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You should also be able to replace first If with &lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/programming-functions.shtml?os=win&amp;amp;source=application#ww5032467" target="_blank" rel="noopener"&gt;As Constant&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(val = 1);
If(!IsMissing(:Value),
	val = val * :Value;
,
	.
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2024 17:41:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743404#M92294</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-02T17:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can you calculate the product of non-empty rows up to the current row?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743421#M92296</link>
      <description>&lt;P&gt;Thank you Jarmo, worked perfectly!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 18:10:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-you-calculate-the-product-of-non-empty-rows-up-to-the/m-p/743421#M92296</guid>
      <dc:creator>Kast</dc:creator>
      <dc:date>2024-04-02T18:10:09Z</dc:date>
    </item>
  </channel>
</rss>

