<?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: Countif equivalent? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664512#M85290</link>
    <description>&lt;P&gt;That makes sense, but then the Col Sum() function is iterating over something...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I imagine it's iterating over the rows that match the current value in the byVar columns, evaluating the expression for each one, then adding up all the results of those evaluations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I have that right?&amp;nbsp; If so, that wording would've been very helpful for me in the Col Sum() scripting index documentation.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2023 17:13:20 GMT</pubDate>
    <dc:creator>BHarris</dc:creator>
    <dc:date>2023-08-01T17:13:20Z</dc:date>
    <item>
      <title>Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/583904#M78996</link>
      <description>&lt;P&gt;I am trying to find a JMP formula function equivalent to Excel’s Countif function, that points to a column and returns the number of rows that are the same as the value in the current row, as you would get if you did a Summary on that row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, if I have a 1000-line table, and column Color is set to "Purple" in 27 rows, I want a formula for a new row that returns 27 for those rows (and the applicable value for the other rows)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I’m sure this is in here, but **bleep** if I can find it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JMP 17, macOS&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:05:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/583904#M78996</guid>
      <dc:creator>DispersionSpark</dc:creator>
      <dc:date>2023-06-09T16:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/583965#M79001</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1671562357735.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/48532i72631355F4DBE390/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1671562357735.png" alt="jthi_0-1671562357735.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Sum(1, :Column 1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2022 18:53:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/583965#M79001</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-12-20T18:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/584158#M79005</link>
      <description>&lt;P&gt;Exactly - thank you!&lt;/P&gt;&lt;P&gt;(and the JMP help text on Col Sum sure is unintuitive...)&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 21:43:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/584158#M79005</guid>
      <dc:creator>DispersionSpark</dc:creator>
      <dc:date>2022-12-20T21:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/584232#M79010</link>
      <description>&lt;P&gt;Which help text do you mean and what is unintuitive with it?&amp;nbsp;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://www.jmp.com/support/help/en/16.2/#page/jmp/statistical-functions-2.shtml?os=win&amp;amp;source=application#ww4579093" target="_blank" rel="noopener"&gt;Col Sum(name,&amp;lt;By var, ...&amp;gt;)&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also from Scripting Index (found from JMP's Help menu) you can get executable demo scripts which can sometimes be helpful&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1671599866563.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/48569iBAC727A2AACD1828/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1671599866563.png" alt="jthi_0-1671599866563.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 05:18:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/584232#M79010</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-12-21T05:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664280#M85263</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;:&amp;nbsp; The help text says the first argument to Col Sum() is "xCol", but you just have a "1" in there.&amp;nbsp; What is JMP doing with that number 1 here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(This is very useful, we had this question today too.)&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 03:23:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664280#M85263</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-08-01T03:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664310#M85266</link>
      <description>&lt;P&gt;It is using 1 for the value of the row instead of a specific value found from some column's row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: In this case I think using Col Number(:Column 1, :Column 1) should also work.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 18:31:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664310#M85266</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-01T18:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664313#M85267</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1893"&gt;@Audrey_Shull&lt;/a&gt;&amp;nbsp; maybe the &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp; example can be added to the scripting index with an explanation, something like "The first argument of the column formula is an expression that is evaluated for each row. It is usually a column, which sums the values of the column, but in this example it is a constant 1 which sums to the count of the rows. That is useful in this example because the second argument is the by-column, which makes the sums be for each by-value."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding the countif keyword might help someone find it in the future (I'm not excel proficient, so maybe look up countif first...)&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 11:04:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664313#M85267</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-08-01T11:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664401#M85274</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp; So, if the first entry is a column object, the Col Sum() function steps over the values in the column (honoring the byVar setting) summing the values, but if the first entry is just a number it just uses that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can the first entry be any expression that returns a value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can it also return a list that gets stepped over similar to providing a column object?&amp;nbsp; What if the length of that list doesn't match the length of the byVar list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This internal behavior of JMP is fascinating and I'd love to learn more about it, but I can't find anything in the docs to help me develop a mental model of what it's doing in cases like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, countif is an excel function that counts all items of a range of cells that meet some criteria.&amp;nbsp; I don't think Col Sum() does exactly that, there doesn't seem to be a way to use it to count the number of cases where col1 &amp;gt; 7 and col2 == 15, for example.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 14:40:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664401#M85274</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-08-01T14:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664452#M85284</link>
      <description>&lt;P&gt;Think of the first argument as an expression. An expression can be&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;42&lt;/LI&gt;
&lt;LI&gt;:height&lt;/LI&gt;
&lt;LI&gt;:height *2 &amp;gt; :weight&lt;/LI&gt;
&lt;LI&gt;if ( :height *2 &amp;gt; :weight, age, 99 )&lt;/LI&gt;
&lt;LI&gt;if ( :height&amp;gt;60 &amp;amp; :weight&amp;gt; 100, 1, 0 )&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;All of those are evaluated in the context of the current row, so using the current row's height and weight and age values. The &amp;gt; operator returns 1 for true and 0 for false, so that can be summed as well. The if evaluates to either age or 99 on each row and that gets summed. And just using :height also gets evaluated to return the current row's value.&lt;/P&gt;
&lt;P&gt;I admit, I looked at &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp; example for a minute before I got it. If you build this into code, add a comment for whoever has to maintain it next!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 16:12:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664452#M85284</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-08-01T16:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664512#M85290</link>
      <description>&lt;P&gt;That makes sense, but then the Col Sum() function is iterating over something...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I imagine it's iterating over the rows that match the current value in the byVar columns, evaluating the expression for each one, then adding up all the results of those evaluations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I have that right?&amp;nbsp; If so, that wording would've been very helpful for me in the Col Sum() scripting index documentation.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 17:13:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664512#M85290</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-08-01T17:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664561#M85298</link>
      <description>&lt;P&gt;Close, I think. I was never in that C++ code, but I believe on the very first call (typically for row 1) it preprocesses all the rows to cache all the possible by-value answers. Then all subsequent rows are answered from that by-value cache. (Without the cache it would be an order(N^2) time for N rows, with the cache just order(N) - linear time.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 17:54:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/664561#M85298</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-08-01T17:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Countif equivalent?</title>
      <link>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/783508#M96789</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1893"&gt;@Audrey_Shull&lt;/a&gt;&amp;nbsp;If you plan to add &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt; 's example in a future version of Scripting Index or Online Help , please also add a paragraph about the magic of&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/Discussions/JMP-equivalent-of-Excel-s-COUNTIF-function/m-p/783500/highlight/true#M96784" target="_blank"&gt;https://community.jmp.com/t5/Discussions/JMP-equivalent-of-Excel-s-COUNTIF-function/m-p/783500/highlight/true#M96784&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:30:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Countif-equivalent/m-p/783508#M96789</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-08-22T18:30:15Z</dc:date>
    </item>
  </channel>
</rss>

