<?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 to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445665#M69350</link>
    <description>&lt;P&gt;1. How is the number of occurrences calculated from the first 3 columns?&amp;nbsp; It can easily be bypassed if you can determine what the value should be.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; JMP will get confused with a column name of Sub-set.&amp;nbsp; JMP will look at the value and try to subtract the value of set from the value of Sub.&amp;nbsp; The notation of :"Sub-set"n tells JMP to use the whole string as the column name.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Dec 2021 06:40:52 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-12-16T06:40:52Z</dc:date>
    <item>
      <title>How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445206#M69318</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&amp;nbsp;I am trying to find out number of times alarm trigged. I have created a column "Number of Occurrence" based on simple logic --&amp;nbsp; If Data in Row () &amp;gt; Row()+1, trigger re-seted. But I am getting lot of false alarm, as seen in the image. The new login I want to implement -&lt;BR /&gt;&lt;BR /&gt;If (&lt;BR /&gt;(Row() - Row()+1) &amp;gt;= Abs(Max(Data))/10, Reset the trigger, otherwise live it as it is&amp;nbsp;&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;Something like that.&lt;BR /&gt;&lt;BR /&gt;I am able to do it in a bit log way, like making summary table and then adding column from summary table and then comparing each value with new column. It works fine but making my script slow.&lt;BR /&gt;&lt;BR /&gt;Is there any better way to implement it within formula or in For loop ?&lt;BR /&gt;&lt;BR /&gt;Any help.&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hari_0-1639557825313.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38419i9B60847393C3140F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hari_0-1639557825313.png" alt="Hari_0-1639557825313.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:07:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445206#M69318</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2023-06-09T18:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445227#M69321</link>
      <description>&lt;P&gt;You can use Col Max() function to get maximum value within groups and Lag() to compare between rows in column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you provide datatable with "correct" results to make it a bit easier to understand the logic behind alarms? Or do just just want to check if current Data value is larger than previous value within group (ID and Sub-set)?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 10:29:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445227#M69321</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-12-15T10:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445230#M69323</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have added a column - "No. of Occurrence - Corrected".&amp;nbsp; Which shows the correct (desired) results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hari_0-1639565149176.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38420iE9990C09963043AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hari_0-1639565149176.png" alt="Hari_0-1639565149176.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 10:46:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445230#M69323</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2021-12-15T10:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445417#M69327</link>
      <description>&lt;P&gt;You can calculate 10% Max directly with formula:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Max(:Data, :ID, :"Sub-set"n)*0.1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm still not sure how the occurrences should be counted, because it seems to never reset, but might move back by 1 value. To check values data column values which are after "current row" you can use Lag(:Data, - 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1639575522323.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38447i99692BB3066C002C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1639575522323.png" alt="jthi_0-1639575522323.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rule you have would look something like this as one formula:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(:Data - Lag(:Data, -1) &amp;gt;= Abs(Col Max(:Data, :ID, :"Sub-set"n)) / 10,
	1,
	0
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Dec 2021 13:50:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445417#M69327</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-12-15T13:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445654#M69346</link>
      <description>&lt;P&gt;It is not working. Somehow I am not able to implement - "Col Max(:Data , Group by{ID, Sub-set})" something like this.&lt;BR /&gt;&lt;BR /&gt;I am able to call value from summary table to the column formula of main table, it is better than my original solution.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 04:37:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445654#M69346</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2021-12-16T04:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445659#M69348</link>
      <description>&lt;P&gt;I have come up with a formula that appears to work.........&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1639633259250.png" style="width: 606px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38460i14576BB119B9C591/image-dimensions/606x382?v=v2" width="606" height="382" role="button" title="txnelson_0-1639633259250.png" alt="txnelson_0-1639633259250.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;There is a discrepancy with your No. of Occurrence - Corrected.&amp;nbsp; On Row 32, I believe .13 - 08 results in .05 which is greater than .034, which should increase the number of occurrence.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1639633485071.png" style="width: 615px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38461iFD178754903CCC22/image-dimensions/615x153?v=v2" width="615" height="153" role="button" title="txnelson_1-1639633485071.png" alt="txnelson_1-1639633485071.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Your implementation of an additional occurance is also not applied until the row after it is discovered.&amp;nbsp; Therefore, using your formula has to have a little trickery put into it, to not apply the change until the next row is processed.&amp;nbsp; Below is my formula that I used for "Jim's Calculation" column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1 | :ID != Lag( :ID ) | :"Sub-set"n != Lag( :"Sub-set"n ),
	hold = :Number of Occurance;
	applyRow = 0;
);
If( :Data - Lag( :Data, -1 ) &amp;gt;= Abs( Col Max( :Data, :ID, :"Sub-set"n ) ) / 10,
	applyRow = Row() + 1
);
If( Row() == applyRow,
	applyRow = 0;
	hold = hold + 1;
);
hold;&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>Thu, 16 Dec 2021 05:51:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445659#M69348</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-16T05:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445662#M69349</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, It worked. many thanks.&lt;BR /&gt;&lt;BR /&gt;Few things -&lt;BR /&gt;1. Your formula is working. But it is taking "No. of Occurrence" as a input for "hold" in row number 2. Is there any way we can bypass that column. (let say, I do not have my original&amp;nbsp;"No. of Occurrence" column!). Can we get correct No. of Occurrence based on just first 3 columns ? I do not want to depend upon that columns, if tomorrow I found some other type of false alarm, not covered here !&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hari_0-1639635429412.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38462i3CAD9609321C8141/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hari_0-1639635429412.png" alt="Hari_0-1639635429412.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. What is 'n' next to "Sub-set" --&amp;nbsp;"Sub-set"n ? I did not get it from Jim's suggestion as well. Any reference for it ?&lt;BR /&gt;&lt;BR /&gt;3. At Row 32 Occurrence should increased. I did changed few values manually and it was my mistake.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 06:22:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445662#M69349</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2021-12-16T06:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445665#M69350</link>
      <description>&lt;P&gt;1. How is the number of occurrences calculated from the first 3 columns?&amp;nbsp; It can easily be bypassed if you can determine what the value should be.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; JMP will get confused with a column name of Sub-set.&amp;nbsp; JMP will look at the value and try to subtract the value of set from the value of Sub.&amp;nbsp; The notation of :"Sub-set"n tells JMP to use the whole string as the column name.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 06:40:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445665#M69350</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-16T06:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445666#M69351</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I understand that my starting point for for No. of Occurrence is not same every set of data. (Some times it is 1 and sometimes it is 2 and so on). So it is not possible to eliminate that column fully. But just as dummy column I can replace first "hold =1" and then it works as a counter.&lt;BR /&gt;&lt;BR /&gt;but my other question is still need some help --&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. What is 'n' next to "Sub-set" --&amp;nbsp;"Sub-set"n ? I did not get it from Jim's suggestion as well. Any reference for it ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;2. and one more -&amp;nbsp; I think&lt;BR /&gt;Dif(:Data) == :Data - Lag(:Data, -1)&amp;nbsp; &amp;nbsp; &amp;nbsp;-- is this correct ?&lt;BR /&gt;&lt;BR /&gt;Is there any benefit using one over the other ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 06:42:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445666#M69351</guid>
      <dc:creator>HSS</dc:creator>
      <dc:date>2021-12-16T06:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to recall a aggregated value (mean/Max etc) based on a grouped column in Formula or in For-Loop</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445667#M69352</link>
      <description>&lt;P&gt;The Scripting Guide found in the JMP Documentation Library, available under the Help pull down menu documents the "name"n reference&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Names&lt;/STRONG&gt;&lt;BR /&gt;A name is simply something to call an item. When you assign the numeric value 3 to a variable &lt;BR /&gt;in the expression a = 3, a is a name.&lt;BR /&gt;Commands and functions have names, too. In the expression Log( 4 ), Log is the name of the &lt;BR /&gt;logarithmic function.&lt;BR /&gt;Names have a few rules:&lt;BR /&gt;• Names must start with an alphabetic character or underscore and can continue with the &lt;BR /&gt;following:&lt;BR /&gt;– alphabetic characters (a-z A-Z)&lt;BR /&gt;– numeric digits (0-9)&lt;BR /&gt;– whitespace characters (spaces, tabs, line endings, and page endings)&lt;BR /&gt;– mathematical symbols in Unicode (such as the Greek small alpha letter α)&lt;BR /&gt;– a few punctuation marks or special characters (apostrophes (‘), percent signs (%), &lt;BR /&gt;periods (.), backslashes (\), and underscores (_))&lt;BR /&gt;• When comparing names, JMP ignores whitespace characters (such as spaces, tabs, and line &lt;BR /&gt;endings). Upper case and lower case characters are not distinguished. For example, the &lt;BR /&gt;names Forage and for age are equivalent, despite the differences in white space and &lt;BR /&gt;case.&lt;BR /&gt;You can still have a name that is any other sequence of characters. If the name does not follow &lt;BR /&gt;the rules above, it needs to be quoted and followed by "n". For example, to use a global &lt;BR /&gt;variable with the name taxable income(2011), you must use "taxable income(2011)"n&lt;BR /&gt;every time the variable appears in a script:&lt;BR /&gt;"taxable income( 2011 )"n = 456000;&lt;BR /&gt;tax = .25;&lt;BR /&gt;Print( tax * "taxable income( 2011 )"n) ;&lt;BR /&gt;114000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are going to get into JSL, then you really need to read the Scripting Guide, cover to cover&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 06:49:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-recall-a-aggregated-value-mean-Max-etc-based-on-a-grouped/m-p/445667#M69352</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-16T06:49:54Z</dc:date>
    </item>
  </channel>
</rss>

