<?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: Setting Values in  a Column with Choose in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780781#M96313</link>
    <description>&lt;P&gt;You are using &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/conditional-and-logical-functions.shtml?os=win&amp;amp;source=application#ww4890947" target="_blank" rel="noopener"&gt;For Each Row&lt;/A&gt; incorrectly. You don't send it to a column, it is a function you provide with (optional) data table and body argument and within body you can set values to columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is fixed version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

startTime = 3742070400;
endTime = 3742074000;

dt = New Table("Test",
	Add Rows(60),
	New Column("Timestamp", Format("m/d/y h:m", 19), Set Display Width(175))
);

For Each Row(:Timestamp[] = Sequence(startTime, endTime, 60)); 

aggOption = 1;

New Column("Agg Minute", Numeric, "Ordinal", Format("Best", 12), Set Display Width(116));


For Each Row(dt,
	:"Agg Minute"n = Choose(aggOption,
		If(
			Minute(:Timestamp) &amp;lt; 15, 15,
			Minute(:Timestamp) &amp;lt; 30, 30,
			Minute(:Timestamp) &amp;lt; 45, 45,
			0
		),
		If(
			Minute(:Timestamp) &amp;lt; 14, 0,
			Minute(:Timestamp) &amp;lt; 29, 15,
			Minute(:Timestamp) &amp;lt; 44, 30,
			45
		),
		If(
			0 &amp;lt; Minute(:Timestamp) &amp;lt;= 15, 15,
			15 &amp;lt; Minute(:Timestamp) &amp;lt;= 30, 30,
			30 &amp;lt; Minute(:Timestamp) &amp;lt;= 45, 45,
			0
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 11 Aug 2024 05:15:04 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-08-11T05:15:04Z</dc:date>
    <item>
      <title>Setting Values in  a Column with Choose</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780770#M96311</link>
      <description>&lt;P&gt;I'm having what I'm sure is a simple issue with setting values in a column using the Choose function. Below is a test script along with a table showing desired output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

startTime = 3742070400;
endTime = 3742074000;

dt = New Table( "Test",
	Add Rows( 60 ),
	New Column( "Timestamp", Format( "m/d/y h:m", 19 ), Set Display Width( 175 ) )
);

For Each Row( :Timestamp[] = Sequence( startTime, endTime, 60 ) ); 

aggOption = 1; // This will eventually be a pulldown menu with choices

New Column( "Agg Minute",
	Numeric,
	"Ordinal",
	Format( "Best", 12 ),
	Set Display Width( 116 )
);

// Script below is the problem. I tried For Each Row and Set Values and a combination
// of both but the column always is blank. See Interpolated Data table for what it
// should look like.

dt:"Agg Minute"n &amp;lt;&amp;lt; For Each Row(
	Choose( aggOption,
		If(
			Minute( :Timestamp ) &amp;lt; 15, 15,
			Minute( :Timestamp ) &amp;lt; 30, 30,
			Minute( :Timestamp ) &amp;lt; 45, 45,
			0
		),
		If(
			Minute( :Timestamp ) &amp;lt; 14, 0,
			Minute( :Timestamp ) &amp;lt; 29, 15,
			Minute( :Timestamp ) &amp;lt; 44, 30,
			45
		),
		If(
			0 &amp;lt; Minute( :Timestamp ) &amp;lt;= 15, 15,
			15 &amp;lt; Minute( :Timestamp ) &amp;lt;= 30, 30,
			30 &amp;lt; Minute( :Timestamp ) &amp;lt;= 45, 45,
			0
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Notice when you run the script the Agg Minute column is blank. I've tried Set Values and For Each Row and a combination of both but I can't seem to get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As always, any assistance is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2024 20:23:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780770#M96311</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-08-10T20:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Values in  a Column with Choose</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780780#M96312</link>
      <description>&lt;P&gt;I can get it to work as a column formula if I set a local variable. But then I can't use my combo box result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is that code. There is obviously much more I need to learn about JSL. It is very easy to auto-generate code. But often when I try to customize it, it breaks and I don't know enough yet to fix it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Arrgh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column( "Agg Minute",
	Numeric,
	"Ordinal",
	Format( "Best", 12 ),
	Set Display Width( 116 ),
	Formula(
		Local( {aggOption = 1},
			Choose( aggOption,
				If(
					Minute( :Timestamp ) &amp;lt; 15, 15,
					Minute( :Timestamp ) &amp;lt; 30, 30,
					Minute( :Timestamp ) &amp;lt; 45, 45,
					0
				),
				If(
					Minute( :Timestamp ) &amp;lt; 15, 0,
					Minute( :Timestamp ) &amp;lt; 30, 15,
					Minute( :Timestamp ) &amp;lt; 45, 30,
					45
				),
				If(
					0 &amp;lt; Minute( :Timestamp ) &amp;lt;= 15, 15,
					15 &amp;lt; Minute( :Timestamp ) &amp;lt;= 30, 30,
					30 &amp;lt; Minute( :Timestamp ) &amp;lt;= 45, 45,
					0
				)
			)
		)
	) 
	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Aug 2024 04:47:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780780#M96312</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-08-11T04:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Values in  a Column with Choose</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780781#M96313</link>
      <description>&lt;P&gt;You are using &lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/conditional-and-logical-functions.shtml?os=win&amp;amp;source=application#ww4890947" target="_blank" rel="noopener"&gt;For Each Row&lt;/A&gt; incorrectly. You don't send it to a column, it is a function you provide with (optional) data table and body argument and within body you can set values to columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is fixed version&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

startTime = 3742070400;
endTime = 3742074000;

dt = New Table("Test",
	Add Rows(60),
	New Column("Timestamp", Format("m/d/y h:m", 19), Set Display Width(175))
);

For Each Row(:Timestamp[] = Sequence(startTime, endTime, 60)); 

aggOption = 1;

New Column("Agg Minute", Numeric, "Ordinal", Format("Best", 12), Set Display Width(116));


For Each Row(dt,
	:"Agg Minute"n = Choose(aggOption,
		If(
			Minute(:Timestamp) &amp;lt; 15, 15,
			Minute(:Timestamp) &amp;lt; 30, 30,
			Minute(:Timestamp) &amp;lt; 45, 45,
			0
		),
		If(
			Minute(:Timestamp) &amp;lt; 14, 0,
			Minute(:Timestamp) &amp;lt; 29, 15,
			Minute(:Timestamp) &amp;lt; 44, 30,
			45
		),
		If(
			0 &amp;lt; Minute(:Timestamp) &amp;lt;= 15, 15,
			15 &amp;lt; Minute(:Timestamp) &amp;lt;= 30, 30,
			30 &amp;lt; Minute(:Timestamp) &amp;lt;= 45, 45,
			0
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Aug 2024 05:15:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780781#M96313</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-11T05:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Values in  a Column with Choose</title>
      <link>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780806#M96323</link>
      <description>&lt;P&gt;Thanks much, Jarmo. It worked like a charm.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2024 13:08:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Setting-Values-in-a-Column-with-Choose/m-p/780806#M96323</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2024-08-11T13:08:50Z</dc:date>
    </item>
  </channel>
</rss>

