<?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 JSL- Formula for calculating column average for last x rows per ID in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Formula-for-calculating-column-average-for-last-x-rows-per/m-p/801763#M97760</link>
    <description>&lt;P&gt;I am trying to create a column formula to calculate the average for the last 30 sets of data per cycle run (shown in the example below):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AvgLlama27_0-1727273049807.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68573i8B64A2641C6F3780/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AvgLlama27_0-1727273049807.png" alt="AvgLlama27_0-1727273049807.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been able to achieve this, however I would like to be able to calculate the average per "ID" rather than the entire data set per test cycle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula I have used is shown below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == Col Max( Row(), :Cycle ),
	Mean( As Column( "Output, mV" )[Index( Row() - 29, Col Max( Row(), :Cycle ) )] )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...but I am unsure of where to go next.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2024 14:06:49 GMT</pubDate>
    <dc:creator>AvgLlama27</dc:creator>
    <dc:date>2024-09-25T14:06:49Z</dc:date>
    <item>
      <title>JSL- Formula for calculating column average for last x rows per ID</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Formula-for-calculating-column-average-for-last-x-rows-per/m-p/801763#M97760</link>
      <description>&lt;P&gt;I am trying to create a column formula to calculate the average for the last 30 sets of data per cycle run (shown in the example below):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AvgLlama27_0-1727273049807.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68573i8B64A2641C6F3780/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AvgLlama27_0-1727273049807.png" alt="AvgLlama27_0-1727273049807.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been able to achieve this, however I would like to be able to calculate the average per "ID" rather than the entire data set per test cycle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula I have used is shown below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == Col Max( Row(), :Cycle ),
	Mean( As Column( "Output, mV" )[Index( Row() - 29, Col Max( Row(), :Cycle ) )] )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...but I am unsure of where to go next.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 14:06:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Formula-for-calculating-column-average-for-last-x-rows-per/m-p/801763#M97760</guid>
      <dc:creator>AvgLlama27</dc:creator>
      <dc:date>2024-09-25T14:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: JSL- Formula for calculating column average for last x rows per ID</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Formula-for-calculating-column-average-for-last-x-rows-per/m-p/801788#M97761</link>
      <description>&lt;P&gt;Have you checked out if &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/statistical-functions-2.shtml?os=win&amp;amp;source=application#ww6133391" target="_blank" rel="noopener"&gt;Col Moving Average&lt;/A&gt; could do what you are looking for?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt &amp;lt;&amp;lt; new column("avg", Numeric, Continuous, Formula(
	If(Row() == Col Max(Row(), :sex),
		Col Moving Average(:height, 1, 9, 0, 1, :sex);
	);
));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2024 15:00:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Formula-for-calculating-column-average-for-last-x-rows-per/m-p/801788#M97761</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-09-25T15:00:58Z</dc:date>
    </item>
  </channel>
</rss>

