<?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: Conditional Column number calculation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870611#M103405</link>
    <description>&lt;P&gt;welcome.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Apr 2025 17:12:35 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-04-28T17:12:35Z</dc:date>
    <item>
      <title>Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870410#M103365</link>
      <description>&lt;P class="ds-markdown-paragraph"&gt;For each&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;ID&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;group in the data table, I like to calculate:&lt;/P&gt;
&lt;OL start="1"&gt;
&lt;LI&gt;
&lt;P class="ds-markdown-paragraph"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;count of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Part Number&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;RANK_DESC = 1&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P class="ds-markdown-paragraph"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;count of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Part Number&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;RANK_ASC = 1&amp;nbsp;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReliabilityWolf_0-1745749897393.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75219iB37346FFBB9C212B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ReliabilityWolf_0-1745749897393.png" alt="ReliabilityWolf_0-1745749897393.png" /&gt;&lt;/span&gt;
&lt;P&gt;I like to add&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;two new columns PN Count of RANK_DEC =1,&amp;nbsp;PN Count of RANK_ASC=1. any formulas to apply for them?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;SPAN&gt;any other better methods to approach? thanks very much in advanced!&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 27 Apr 2025 10:35:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870410#M103365</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2025-04-27T10:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870421#M103366</link>
      <description>&lt;P&gt;For conditional calculation, JMP provides the &lt;FONT face="courier new,courier"&gt;Col XYZ()&lt;/FONT&gt; aggregation functions.&lt;BR /&gt;For counting, you can use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Col Number(). &lt;/FONT&gt;It counts any non-missing entry.&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;To convert non-matching rows to "missing", you need something like&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Col sum (if(Rank_ASC==1 ,1,.),:Part_Number).&lt;BR /&gt;&lt;/FONT&gt;If Rank is 1, the &lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt; expression returns 1, for the other rows, it will return "."&amp;nbsp; (missing) - and JMP doesn't count the row.&lt;BR /&gt;&lt;BR /&gt;After a first argument for the numeric input, you can specify additional columns (and expressions) to specify byGroups.&lt;BR /&gt;With &lt;FONT face="courier new,courier"&gt;:Part_Number&lt;/FONT&gt; as the second argument, JMP will create separate counts for each :Part_Number.&lt;BR /&gt;&lt;BR /&gt;I prefer &lt;FONT face="courier new,courier"&gt;Col Sum().&lt;BR /&gt;&lt;/FONT&gt;To count specific rows, you can use a comparison like&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Col sum (Rank_ASC==1 , :Part_Number ).&lt;BR /&gt;&lt;/FONT&gt;The idea behind the expression: &lt;BR /&gt;For rows with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;rank 1, &lt;/FONT&gt;the result of&amp;nbsp; the comparison&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Rank_ASC==1 &lt;/FONT&gt;is 1, for the other rows the result is 0.&lt;BR /&gt;So, &lt;FONT face="courier new,courier"&gt;col sum&lt;/FONT&gt; will count all rows with rank=1.&lt;BR /&gt;Here, we use again&amp;nbsp;&lt;FONT face="courier new,courier"&gt;:Part_Number&lt;/FONT&gt; as a second argument. So, counts will be separate for the different Part_Numbers.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "parts",
	Add Rows( 7 ),
	New Column( "ID",
		Character,
		Set Values( {"U30372", "W30569", "W30569", "Q40040", "P40051", "P40051", "P40051"} )
	),
	New Column( "Part_Number",
		Character,
		Set Values( {"T772", "T772", "T772", "T772", "T770", "T772", "T770"} )
	),
	New Column( "Rank_ASC", Formula( Col Rank( :Part_Number, :ID ) ) ),
	New Column( "PN_Count_Rank_ASC",
		Formula( Col Sum( :Rank_ASC == 1, :Part_Number ) ),
		Set Display Width( 156 )
	),
	New Column( "RANK_DESC",
		Formula( (Col Number( :Part_Number, :ID ) - Col Rank( :Part_Number, :ID )) + 1 )
	),
	New Column( "PN_Count_Rank_DESC", Formula( Col Sum( :RANK_DESC == 1, :Part_Number ) ) )
)&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 14:05:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870421#M103366</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-27T14:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870424#M103367</link>
      <description>&lt;P&gt;sorry for my unclear statement.&lt;/P&gt;
&lt;P&gt;here is my expectation:&amp;nbsp; for example,&amp;nbsp;In "P40051" group, Part_number of Rank_ASC_1 == "T770", the count of "T770" in this group is 2, similar thing, Part_number of Rank_DESC_1 == "T772", the count of "T772" in this group is 1.&amp;nbsp; in "Q40040" group, Part_number of Rank_ASC_1 and&amp;nbsp;Part_number of Rank_DESC_1 == "T770", the count of&amp;nbsp;Part_number of Rank_DESC_1 or&amp;nbsp;the count of "T770" in this group is 1. here is my expected result in right 2 columns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReliabilityWolf_0-1745767157976.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75224i117023982A1952C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ReliabilityWolf_0-1745767157976.png" alt="ReliabilityWolf_0-1745767157976.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;attached the data file for check.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 15:19:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870424#M103367</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2025-04-27T15:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870427#M103368</link>
      <description>&lt;P&gt;Ah, right, I mixed&amp;nbsp; up the&lt;BR /&gt;&lt;EM&gt;For each&amp;nbsp;&lt;CODE&gt;ID&lt;/CODE&gt;&amp;nbsp;group&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with&lt;EM&gt;&lt;BR /&gt;&lt;SPAN&gt;For each&lt;/SPAN&gt;&lt;CODE&gt;Part_Number&lt;/CODE&gt;&lt;SPAN&gt;group&lt;/SPAN&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 15:19:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870427#M103368</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-27T15:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870428#M103369</link>
      <description>&lt;P&gt;This code should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "parts",
	Add Rows( 7 ),
	New Column( "ID",
		Character,
		Set Values( {"U30372", "W30569", "W30569", "Q40040", "P40051", "P40051", "P40051"} )
	),
	New Column( "Part_Number",
		Character,
		Set Values( {"T772", "T772", "T772", "T772", "T770", "T772", "T770"} )
	),
	New Column( "Rank_ASC", Formula( Col Rank( :Part_Number, :ID ) ) ),
	New Column( "PN_Count_Rank_ASC=1",
		Formula( Col Sum( Col Rank(:Part_Number, :ID,&amp;lt;&amp;lt; tie(minimum)) ==1,  :ID ) ),
	),&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;With the &lt;FONT face="courier new,courier"&gt;&amp;lt;&amp;lt; tie(minimum)&lt;/FONT&gt; option, every row with the Rank 1 Part_Number will get Rank=1 - such that all such rows get counted. For this case, we can skip the intermediate step of calculating the Rank.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 15:31:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870428#M103369</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-27T15:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870429#M103370</link>
      <description>&lt;P&gt;Without the &lt;FONT face="courier new,courier"&gt;&amp;lt;&amp;lt;tie&lt;/FONT&gt; option, additional rows with the same ID / Part_Number will get incremental Ranks.&lt;BR /&gt;&lt;BR /&gt;Here you can use a &lt;FONT face="courier new,courier"&gt;Col min( )&lt;/FONT&gt;&amp;nbsp;to replicate the Rank=1 information in all the rows of the same ID/Part_number:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;get the minimum rank of the combination :Part_Number / :ID :&lt;BR /&gt;&lt;CODE class=" language-jsl"&gt;Col Minimum( :RANK_ASC,:Part_Number, :ID)&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;if this min rank is 1,&amp;nbsp;mark the row:&lt;BR /&gt;&lt;CODE class=" language-jsl"&gt;Col Minimum( ... ) == 1&lt;/CODE&gt;&lt;BR /&gt;for these rows, the result is 1, all the other rows get 0&lt;/LI&gt;
&lt;LI&gt;for every ID, count the 1s:&lt;BR /&gt;&lt;CODE class=" language-jsl"&gt;Col sum( ... ,  :ID )&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;With this approach &lt;FONT face="courier new,courier"&gt;count_Rank_ASC&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;count_Rank_DESC&lt;/FONT&gt; can be constructed with a similar code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "parts",
	Add Rows( 7 ),
	New Column( "ID",
		Character,
		Set Values( {"U30372", "W30569", "W30569", "Q40040", "P40051", "P40051", "P40051"} )
	),
	New Column( "Part_Number",
		Character,
		Set Values( {"T772", "T772", "T772", "T772", "T770", "T772", "T770"} )
	),
	New Column( "Rank_ASC", Formula( Col Rank( :Part_Number, :ID ) ) ),
	
	New Column( "PN_Count_Rank_ASC=1",
		Formula( Col sum(Col Minimum( :RANK_ASC,:Part_Number, :ID) ==1,  :ID ))
	),
	New Column( "RANK_DESC",
		Formula( (Col Number( :Part_Number, :ID ) - Col Rank( :Part_Number, :ID )) + 1 )
	),
	
	New Column( "PN_Count_Rank_DESC=1",
		Formula( Col sum(Col Minimum( :RANK_DESC,:Part_Number, :ID) ==1,  :ID ))
	)	
)  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 16:33:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870429#M103370</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-27T16:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870430#M103371</link>
      <description>&lt;P&gt;in my table, "RANK_ASC" column have been over there, I am not sure if it's defined by col Rank(:Part_Number, :ID). but I like to base on the value of RANK_ASC (RANK_ASC==1) to find the specific Part_Number, then expect the appropriate formular to calculate the count of Part_number in this group.&amp;nbsp; in your formular, I have no idea how&amp;nbsp;&lt;SPAN&gt;&amp;lt;&amp;lt; tie(minimum) to correlate to&amp;nbsp;RANK_ASC (RAN_ASC==1). by the way, what's the formula for&amp;nbsp;&amp;nbsp;RANK_DESC==1?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 15:52:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870430#M103371</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2025-04-27T15:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870436#M103374</link>
      <description>&lt;P&gt;Here are is one option (there are plenty of other options too)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Col Sum(:Part_Number == :Part_Number[Col Min(If(:RANK_ASC == 1, Row(), .), :ID)], :ID)&amp;nbsp;//change&amp;nbsp;:RANK_ASC&amp;nbsp;to&amp;nbsp;RANK_DESC&amp;nbsp;for&amp;nbsp;other&amp;nbsp;formula&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1745769824387.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75226i3D31B0680061D629/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_1-1745769824387.png" alt="jthi_1-1745769824387.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This type of formula which uses Col Min/Max, If() and Row() can be quite useful. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do note that it might break in any future version of JMP as these functions are not meant to be used this way. In hopes to prevent JMP from making an massive mistake I have created this wish list item &lt;LI-MESSAGE title="Make using formula expressions in Set Each Value and using expressions as first argument in Col statistical formulas supported behaviour" uid="666966" url="https://community.jmp.com/t5/JMP-Wish-List/Make-using-formula-expressions-in-Set-Each-Value-and-using/m-p/666966#U666966" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 16:07:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870436#M103374</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-04-27T16:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870449#M103377</link>
      <description>&lt;P&gt;For RANK_DESC=1, I am sure that one can set up a complicated formula with &amp;lt;&amp;lt; tie.&lt;/P&gt;
&lt;P&gt;Much easier: use the second approach:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870429/highlight/true#M103370" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870429/highlight/true#M103370&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you don't like/trust the &lt;FONT face="courier new,courier"&gt;&amp;lt;&amp;lt; tie()&lt;/FONT&gt; option, use the second approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if Rank_ASC and RANK_DESC are already there in the table, this is a good argument to use the second approach. No need to calculate the columns on your own.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 16:21:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870449#M103377</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-27T16:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870560#M103397</link>
      <description>Thanks for your support, it works</description>
      <pubDate>Mon, 28 Apr 2025 14:47:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870560#M103397</guid>
      <dc:creator>ReliabilityWolf</dc:creator>
      <dc:date>2025-04-28T14:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Column number calculation</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870611#M103405</link>
      <description>&lt;P&gt;welcome.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 17:12:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Column-number-calculation/m-p/870611#M103405</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-28T17:12:35Z</dc:date>
    </item>
  </channel>
</rss>

