<?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 New Column Set Value Help in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351131#M60081</link>
    <description>&lt;P&gt;I know the following script is incorrect:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = {"a", "b", "b"};
b = [1, 2, 3];
c = [4, 5, 6];

New Table( "SQL Results",
    New Column( "a", character, set values( a ) ), 
    New Column( "b", formula( If( :a == "a", set values( b ), set values( c ) ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I change it to make the output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;a&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;&amp;nbsp;b&amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;BR /&gt;&amp;nbsp;b&amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the first row checks if column 1 is "a",&amp;nbsp; yes then use b[1]; second-row checks if column 1 is "a", no then use c[2]; third-row checks if column 1 is "a", no then use c[3].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:03:49 GMT</pubDate>
    <dc:creator>jy06115197</dc:creator>
    <dc:date>2023-06-09T22:03:49Z</dc:date>
    <item>
      <title>New Column Set Value Help</title>
      <link>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351131#M60081</link>
      <description>&lt;P&gt;I know the following script is incorrect:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = {"a", "b", "b"};
b = [1, 2, 3];
c = [4, 5, 6];

New Table( "SQL Results",
    New Column( "a", character, set values( a ) ), 
    New Column( "b", formula( If( :a == "a", set values( b ), set values( c ) ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I change it to make the output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;a&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;&amp;nbsp;b&amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;BR /&gt;&amp;nbsp;b&amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the first row checks if column 1 is "a",&amp;nbsp; yes then use b[1]; second-row checks if column 1 is "a", no then use c[2]; third-row checks if column 1 is "a", no then use c[3].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:03:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351131#M60081</guid>
      <dc:creator>jy06115197</dc:creator>
      <dc:date>2023-06-09T22:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: New Column Set Value Help</title>
      <link>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351150#M60082</link>
      <description>&lt;P&gt;Here is how to do what you want.&amp;nbsp; Please note that JMP had an issue in the formula with the matrix b reference, since the formula was being interpreted as referencing the column b.&amp;nbsp; That is why I changed the column name to b2.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

a = {"a", "b", "b"};
b = [1, 2, 3];
c = [4, 5, 6];


dt = New Table( "SQL Results",
	New Column( "a", character, set values( a ) )
);


dt &amp;lt;&amp;lt; New Column( "b2",
	formula(
		If( :a == "a",
			b[Row()],
			c[Row()]
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To illustrate the scoping issue further, if you really need&amp;nbsp; the column to be named&amp;nbsp; "b" then one can specify the fully scoped name of here:b (the "here" comes from Names Default to Here( 1 ) )&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

a = {"a", "b", "b"};
b = [1, 2, 3];
c = [4, 5, 6];


dt = New Table( "SQL Results",
	New Column( "a", character, set values( a ) )
);


dt &amp;lt;&amp;lt; New Column( "b",
	formula(
		If( :a == "a",
			here:b[Row()],
			c[Row()]
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jan 2021 18:43:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351150#M60082</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-01-20T18:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: New Column Set Value Help</title>
      <link>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351151#M60083</link>
      <description>&lt;P&gt;Nelson,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much. I truly appreciate your help.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 18:45:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/New-Column-Set-Value-Help/m-p/351151#M60083</guid>
      <dc:creator>jy06115197</dc:creator>
      <dc:date>2021-01-20T18:45:43Z</dc:date>
    </item>
  </channel>
</rss>

