<?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: Syntax: How do I create an index column by ID in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9755#M9541</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the below formula will work for IDIndex independently of the initial sorting of the ID column:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum( :ID[Index( 1, Row() )] == :ID )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Oct 2014 15:07:18 GMT</pubDate>
    <dc:creator>ms</dc:creator>
    <dc:date>2014-10-07T15:07:18Z</dc:date>
    <item>
      <title>Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9751#M9537</link>
      <description>&lt;P&gt;Hello JMP Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a column that indexes rows by an ID column.&lt;/P&gt;
&lt;P&gt;In other scripting language, this is accomplished with the following lines.&lt;/P&gt;
&lt;P&gt;By ID: gen IDIndex = _n&lt;/P&gt;
&lt;P&gt;By ID: gen IDCount = _N&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can do the following, but I index and count the whole table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column( "IDIndex", formula( Row() ) );
New Column( "IDCount", formula( N Row() ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Advice on this would be great!&lt;/P&gt;
&lt;P&gt;Very Sincerely,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="jiveBorder" style="border: 1px solid #000000; width: 100%;" border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/TH&gt;
&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;IDIndex&lt;/STRONG&gt;&lt;/TH&gt;
&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;IDCount&lt;/STRONG&gt;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;444&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;444&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;444&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;444&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;
&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sun, 24 Feb 2019 22:19:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9751#M9537</guid>
      <dc:creator>mpg</dc:creator>
      <dc:date>2019-02-24T22:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9752#M9538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your formula you need to check the ID value to see if it has changed from the previous row and reset your index if it has.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this formula:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(:ID != Lag(:ID, 1) | Row() == 1, 1, Lag(:IDIndex, 1) + 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your ID Count column has use IDIndex to get its value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Col Maximum( :IDIndex, :ID )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;The second argument to the Col Maximum function is the By variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 14:25:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9752#M9538</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2014-10-07T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9753#M9539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, that worked perfectly!&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 14:40:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9753#M9539</guid>
      <dc:creator>mpg</dc:creator>
      <dc:date>2014-10-07T14:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9754#M9540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jeff is correct and i will only add that the formula for IDIndex depends on previous sorting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the table needs to be re-sorted later you would need to suppress evaluation or delete it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;column (dt, "IDIndex") &amp;lt;&amp;lt; suppress eval ( true );&lt;/P&gt;&lt;P&gt;or:&lt;/P&gt;&lt;P&gt;column (dt, "IDIndex") &amp;lt;&amp;lt; delete formula;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to produce the column IDCount without sorting you can use the table summery option:&lt;/P&gt;&lt;P&gt;dt &amp;lt;&amp;lt; Summary (Group ( :ID );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 14:54:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9754#M9540</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2014-10-07T14:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9755#M9541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the below formula will work for IDIndex independently of the initial sorting of the ID column:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum( :ID[Index( 1, Row() )] == :ID )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 15:07:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9755#M9541</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2014-10-07T15:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax: How do I create an index column by ID</title>
      <link>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9756#M9542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks MS, the command you shared does work independently of the sorting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 15:59:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Syntax-How-do-I-create-an-index-column-by-ID/m-p/9756#M9542</guid>
      <dc:creator>mpg</dc:creator>
      <dc:date>2014-10-07T15:59:54Z</dc:date>
    </item>
  </channel>
</rss>

