<?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 How to extend a row selection from an If statement in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214222#M42838</link>
    <description>&lt;P&gt;How to extend a row selection from an if statement on same grouping values from an other column? In case of the attached file row 7 is selected with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; select where (:D1 &amp;gt; 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The selection should be extend on all grouping values from column G1, which are in this case all „B“&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sun, 23 Jun 2019 16:57:09 GMT</pubDate>
    <dc:creator>Thomas1</dc:creator>
    <dc:date>2019-06-23T16:57:09Z</dc:date>
    <item>
      <title>How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214222#M42838</link>
      <description>&lt;P&gt;How to extend a row selection from an if statement on same grouping values from an other column? In case of the attached file row 7 is selected with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; select where (:D1 &amp;gt; 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The selection should be extend on all grouping values from column G1, which are in this case all „B“&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 23 Jun 2019 16:57:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214222#M42838</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2019-06-23T16:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214241#M42839</link>
      <description>&lt;P&gt;There are a few different interpretations of your question, but I hope the one I am solving is the correct one.&amp;nbsp; Take a look at my script and tell me if it is what you were thinking of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "IfSelRows",
	Add Rows( 15 ),
	Compress File When Saved( 1 ),
	New Column( "G1",
		Character( 1 ),
		"Nominal",
		Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C"} ),
		Set Display Width( 76 )
	),
	New Column( "D1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
		Set Display Width( 58 )
	)
);

// Get the rows where D1 &amp;gt; 1
d1Rows = dt &amp;lt;&amp;lt; get rows where( :D1 &amp;gt; 1 );

// Create a list with the values of G1 for the rows that have been selected
g1Values = {};
If( N Rows( d1Rows ) &amp;gt; 0,
	For( i = 1, i &amp;lt;= N Rows( d1Rows ), i++,
		Insert Into( g1Values, dt:G1[d1Rows[i]] )
	)
);

// Select the rows where any of the values in the g1List exist
dt &amp;lt;&amp;lt; select where(contains(g1Values,:G1));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 18:34:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214241#M42839</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-06-23T18:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214245#M42842</link>
      <description>&lt;P&gt;Thanks Jim for your fast reply. You got my question right. Your script delivers exactly what I was looking for.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button isShow"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 23 Jun 2019 21:14:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214245#M42842</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2019-06-23T21:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214319#M42849</link>
      <description>&lt;P&gt;Again thanks for to code. It works as intended. What must be changed or added to the code to use it as formula column?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;There are a few different interpretations of your question, but I hope the one I am solving is the correct one.&amp;nbsp; Take a look at my script and tell me if it is what you were thinking of&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "IfSelRows",
	Add Rows( 15 ),
	Compress File When Saved( 1 ),
	New Column( "G1",
		Character( 1 ),
		"Nominal",
		Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C"} ),
		Set Display Width( 76 )
	),
	New Column( "D1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
		Set Display Width( 58 )
	)
);

// Get the rows where D1 &amp;gt; 1
d1Rows = dt &amp;lt;&amp;lt; get rows where( :D1 &amp;gt; 1 );

// Create a list with the values of G1 for the rows that have been selected
g1Values = {};
If( N Rows( d1Rows ) &amp;gt; 0,
	For( i = 1, i &amp;lt;= N Rows( d1Rows ), i++,
		Insert Into( g1Values, dt:G1[d1Rows[i]] )
	)
);

// Select the rows where any of the values in the g1List exist
dt &amp;lt;&amp;lt; select where(contains(g1Values,:G1));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Again thanks for to code. It works as intended. What must be changed or added to the code to use it as formula?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:25:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214319#M42849</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2019-06-24T14:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214323#M42852</link>
      <description>&lt;P&gt;I am not sure what it is that you want to do with a formula version.&amp;nbsp; That is, what values are you anticipating end up in the new column, but below is my guess on what you might want to do. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI, the formula version will not be as efficient as the scripting version, because it will have to execute once for every row.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() == 1,
	dt = Current Data Table();
	d1Rows = dt &amp;lt;&amp;lt; get rows where( :D1 &amp;gt; 1 );
	g1Values = {};
	If( N Rows( d1Rows ) &amp;gt; 0,
		For( i = 1, i &amp;lt;= N Rows( d1Rows ), i++,
			Insert Into( g1Values, dt:G1[d1Rows[i]] )
		)
	);
);
If( Contains( g1Values, :G1 ),
	x = 1;
	Row State( Row() ) = Selected State( 1 );
,
	x = 0
);
x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the data table script with the formula applied&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "IfSelRows",
	Add Rows( 15 ),
	Compress File When Saved( 1 ),
	New Column( "G1",
		Character( 1 ),
		"Nominal",
		Set Values(
			{"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C",
			"C"}
		),
		Set Display Width( 76 )
	),
	New Column( "D1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
		Set Display Width( 58 )
	),
	New Column( "Column 3",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If( Row() == 1,
				dt = Current Data Table();
				d1Rows = dt &amp;lt;&amp;lt; get rows where( :D1 &amp;gt; 1 );
				g1Values = {};
				If( N Rows( d1Rows ) &amp;gt; 0,
					For( i = 1, i &amp;lt;= N Rows( d1Rows ), i++,
						Insert Into( g1Values, dt:G1[d1Rows[i]] )
					)
				);
			);
			If( Contains( g1Values, :G1 ),
				x = 1;
				Row State( Row() ) = Selected State( 1 );
			,
				x = 0
			);
			x;
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 14:59:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214323#M42852</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-06-24T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214400#M42874</link>
      <description>&lt;P&gt;I'm&amp;nbsp;asking for formula column because the data are updated by SQL. An existing&amp;nbsp; formula column with index numbers is being updated automatically with regards to the new data.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 18:28:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214400#M42874</guid>
      <dc:creator>Thomas1</dc:creator>
      <dc:date>2019-06-24T18:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extend a row selection from an If statement</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214423#M42877</link>
      <description>I strongly suggest that if you plan on continuing your using JMP and using JSL, you need to take the time to read the JSL documentation in the Scripting Guide&lt;BR /&gt;     Help==&amp;gt;Books==&amp;gt;Scripting Guide</description>
      <pubDate>Mon, 24 Jun 2019 19:01:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-extend-a-row-selection-from-an-If-statement/m-p/214423#M42877</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-06-24T19:01:41Z</dc:date>
    </item>
  </channel>
</rss>

