<?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: create new column with assigned value by another column value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/256930#M50476</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a possible solution that only uses built in functions assuming that your time values are actually coded as times (and not characters)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	"A",
	If( :Column 1 == Lag( :Column 1, 1 ),
		Lag( :New Column, 1 ),
		Hex To Char( Char( Num( Hex( Lag( :New Column, 1 ) ) ) + 1 ) )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;There might be more elegant ways to achieve this but I'm not aware of a function that allows for easy conversion of characters to numerical code and back&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2020 05:32:02 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2020-04-09T05:32:02Z</dc:date>
    <item>
      <title>create new column with assigned value by another column value</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/256693#M50434</link>
      <description>&lt;P&gt;I have a column with date, and want to create a new column,&amp;nbsp; need assign with {A, B, C, D, E}&amp;nbsp;by judging another column&amp;nbsp;unique date.&lt;/P&gt;&lt;P&gt;Judge by "rundate" cell value(refer to below pic), kindly help on&amp;nbsp;how to generate a script:&lt;/P&gt;&lt;P&gt;1. assign new column Cell[1] == "A", i++,&amp;nbsp;if "rundate" Cell[i] = "rundate" Cell[i++], keep assign new column Cell[i++]=="A".&lt;/P&gt;&lt;P&gt;2. if "rundate" Cell[i]&amp;nbsp;&amp;lt; "rundate" Cell[i++],&amp;nbsp;means date time changed, need assign new column Cell[i++]=="B".&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;if "rundate" Cell[i] = "rundate" Cell[i++], keep assign new column Cell[i++]=="B".&lt;/P&gt;&lt;P&gt;4. if "rundate" Cell[i]&amp;nbsp;&amp;lt; "rundate" Cell[i++],&amp;nbsp;means date time changed again, need assign column Cell[i++]=="C".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rundate&lt;BR /&gt;4/1/2020 7:18&lt;BR /&gt;4/1/2020 7:18&lt;BR /&gt;4/1/2020 7:18&lt;BR /&gt;4/1/2020 7:47&lt;BR /&gt;4/1/2020 8:13&lt;BR /&gt;4/1/2020 8:13&lt;BR /&gt;4/1/2020 8:13&lt;BR /&gt;4/1/2020 8:13&lt;BR /&gt;4/1/2020 8:13&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 8:43&lt;BR /&gt;4/1/2020 9:13&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="Untitled.bmp" style="width: 467px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/22854i16DAF2EBAD4D4B88/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.bmp" alt="Untitled.bmp" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 08:12:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/256693#M50434</guid>
      <dc:creator>qspringleaf</dc:creator>
      <dc:date>2020-04-08T08:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: create new column with assigned value by another column value</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/256930#M50476</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a possible solution that only uses built in functions assuming that your time values are actually coded as times (and not characters)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	"A",
	If( :Column 1 == Lag( :Column 1, 1 ),
		Lag( :New Column, 1 ),
		Hex To Char( Char( Num( Hex( Lag( :New Column, 1 ) ) ) + 1 ) )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;There might be more elegant ways to achieve this but I'm not aware of a function that allows for easy conversion of characters to numerical code and back&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 05:32:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/256930#M50476</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-04-09T05:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: create new column with assigned value by another column value</title>
      <link>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/257688#M50641</link>
      <description>&lt;P&gt;Slightly different approach, and I'm not using letters because there are only 26, and I often have lots more categories.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long at the value in your :ID (or time) column stays the same, then the counter column stays the same, but when it switches, the counter column goes up by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	1,
	If( :ID == Lag( :ID, 1 ),
		Lag( :counter, 1 ),
		Lag( :counter, 1 ) + 1
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;These nested If statements can be really handy, or giant monsters, depending on you point of view.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 16:53:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/create-new-column-with-assigned-value-by-another-column-value/m-p/257688#M50641</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2020-04-13T16:53:43Z</dc:date>
    </item>
  </channel>
</rss>

