<?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: Using FORMULA for pasting the alues from one column based on the other column using IF statement in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547290#M76472</link>
    <description>&lt;P&gt;You could do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1, :Slopes, :Cycle 2 == Lag( :Cycle 2 ), Lag( :Slopes_1 ), :Slopes )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$Sample_data/big class.jmp" );

dt &amp;lt;&amp;lt; New Column( "height_1",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( If( Row() == 1, :height, :age == Lag( :age ), Lag( :height_1 ), :height ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Sep 2022 13:57:40 GMT</pubDate>
    <dc:creator>ih</dc:creator>
    <dc:date>2022-09-21T13:57:40Z</dc:date>
    <item>
      <title>Using FORMULA for pasting the alues from one column based on the other column using IF statement</title>
      <link>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547167#M76465</link>
      <description>&lt;P&gt;I am trying to fill the column of &lt;STRONG&gt;Slopes_1&lt;/STRONG&gt; and &lt;STRONG&gt;Intercept_1 (1000 rows)&lt;/STRONG&gt;&amp;nbsp; from &lt;STRONG&gt;Slopes&lt;/STRONG&gt; and &lt;STRONG&gt;Intercept (36 rows)&lt;/STRONG&gt;, respectively based on if &lt;STRONG&gt;Cycle 2(1000 rows)&amp;nbsp;&lt;/STRONG&gt; matches &lt;STRONG&gt;Cycle 3&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;(36 rows)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can you suggest a formula to be inputted in&amp;nbsp;&lt;STRONG&gt;Slopes_1&lt;/STRONG&gt; and &lt;STRONG&gt;Intercept_1&lt;/STRONG&gt;&amp;nbsp;?&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="AlphaPanda86751_2-1663762127734.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45652i4E5946983D9F469C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlphaPanda86751_2-1663762127734.png" alt="AlphaPanda86751_2-1663762127734.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:54:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547167#M76465</guid>
      <dc:creator>AlphaPanda86751</dc:creator>
      <dc:date>2023-06-10T23:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using FORMULA for pasting the alues from one column based on the other column using IF statement</title>
      <link>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547290#M76472</link>
      <description>&lt;P&gt;You could do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1, :Slopes, :Cycle 2 == Lag( :Cycle 2 ), Lag( :Slopes_1 ), :Slopes )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$Sample_data/big class.jmp" );

dt &amp;lt;&amp;lt; New Column( "height_1",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( If( Row() == 1, :height, :age == Lag( :age ), Lag( :height_1 ), :height ) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Sep 2022 13:57:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547290#M76472</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2022-09-21T13:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using FORMULA for pasting the alues from one column based on the other column using IF statement</title>
      <link>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547335#M76478</link>
      <description>&lt;P&gt;There are many ways of doing this, here is one using associative arrays:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

// Sample data
dt = New Table("Untitled",
	Add Rows(9),
	New Column("C3", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, ., ., ., ., ., .])),
	New Column("S",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([0.11, 0.12, 0.13, ., ., ., ., ., .])
	),
	New Column("I",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1.1, 1.2, 1.3, ., ., ., ., ., .])
	),
	New Column("C2", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 1, 2, 2, 2, 3, 3, 3])),
	New Column("S1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., ., ., ., ., ., ., .])),
	New Column("I1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., ., ., ., ., ., ., .]))
);

wait(1);
// Formulas start
Column(dt, "S1") &amp;lt;&amp;lt; Formula(
	As Constant(
		aa_slope_c3 = Associative Array(Eval List(:c3 &amp;lt;&amp;lt; get values), Eval List(:s &amp;lt;&amp;lt; get values));
	);
	aa_slope_c3[:c2];
);

Column(dt, "I1") &amp;lt;&amp;lt; Formula(
	As Constant(
		aa_intercept_c3 = Associative Array(Eval List(:c3 &amp;lt;&amp;lt; get values), Eval List(:i &amp;lt;&amp;lt; get values));
	);
	aa_intercept_c3[:c2];
);

// If data is always like this, can be simplified to
dt &amp;lt;&amp;lt; New Column("ss", Numeric, Continuous, Formula(
	:S[:C2]
));
dt &amp;lt;&amp;lt; New Column("ii", Numeric, Continuous, Formula(
	:I[:C2]
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you don't need a formula you could also use joins/virtual joins.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1663773104333.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45660i1A4C5786E4F2387E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1663773104333.png" alt="jthi_0-1663773104333.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Formulas can be found from the script or from attached data table&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 15:12:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-FORMULA-for-pasting-the-alues-from-one-column-based-on-the/m-p/547335#M76478</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-21T15:12:10Z</dc:date>
    </item>
  </channel>
</rss>

