<?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: How to get the row number of colored cells in a column and assign it a tag (say &amp;quot;1&amp;quot;) in a newly created column? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/750090#M93068</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Thanks. I have adapted your script to use with a dataset matching closely to mine. It works fine for one column name but not when I loop over column names.&amp;nbsp; Also, how do I place each newly created column beside (on the right of) the column on which the operation is performed within the loop?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Clear Log();

dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

col_names = dt &amp;lt;&amp;lt; Get Column Group( "Processes" );

ps = dt &amp;lt;&amp;lt; Process Screening(
	Process Variables( Eval( col_names ) ),
	Spec Limits Dialog( "No (skip columns with no spec limits)" ),
);

ps &amp;lt;&amp;lt; Color Out Of Spec Values (1);

t = ps &amp;lt;&amp;lt; Get Window Title; //Show( t );
ps &amp;lt;&amp;lt; Close Window;
dt &amp;lt;&amp;lt; Clear Select &amp;lt;&amp;lt; Clear Column Selection;

get_colored_cells = Function({dt, colname}, {Default Local},
	colscript = Column(dt, colname) &amp;lt;&amp;lt; Get Script;
	l = Substitute(Name Expr(colscript), Expr(New Column()), List());
	colored_cells = {};
	Try(
		colors = l["Color Cells"];
		If(Type(colors[1]) == "List",
			jmptrickery = 1;
		,
			jmptrickery = 0;
		);
		For Each({color}, colors,
			If(jmptrickery,
				Insert Into(colored_cells, color[2]);
			,
				Insert Into(colored_cells, color);
			);
		);
	);
	return(Matrix(colored_cells));
);

measColNames = dt &amp;lt;&amp;lt; get column names(Numeric,Continuous ); show (measColNames[1]);

For( i = 1, i &amp;lt;= N Items( measColNames), i++,
	rows = J( 1, N Rows( dt ), 0 );
	colored_rows = get_colored_cells( dt, measColNames[i]);
	rows[colored_rows] = 1;
	dt &amp;lt;&amp;lt; New Column( "PassFail"||measColNames[i], Numeric, Nominal, Values( rows ) );
);


//colname = "NPN1";
///// for single column
/*rows = J(1, N Rows(dt), 0);
colored_rows = get_colored_cells(dt, colname);
rows[colored_rows] = 1;
dt &amp;lt;&amp;lt; New Column("result", Numeric, Nominal, Values(rows));*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Apr 2024 10:28:54 GMT</pubDate>
    <dc:creator>Neo</dc:creator>
    <dc:date>2024-04-26T10:28:54Z</dc:date>
    <item>
      <title>How to get the row number of colored cells in a column and assign it a tag (say "1") in a newly created column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/749264#M92964</link>
      <description>&lt;P&gt;I used Color Out of Spec Values() to color spec fails in my measurement data. I have multiple columns with measurement data and the out of spec values for each column get colored according to the spec for each parameter column.&lt;/P&gt;&lt;P&gt;For each parameter column I want to create an adjacent column which assigns a "1" when the cell is colored otherwise "0".&lt;/P&gt;&lt;P&gt;How to achieve this via JSL?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 10:14:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/749264#M92964</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2024-04-24T10:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the row number of colored cells in a column and assign it a tag (say "1") in a newly created column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/749287#M92967</link>
      <description>&lt;P&gt;This gives idea how you can handle the situation for one column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
a = {1, 3, 5};
b = {2, 4, 6};
c = {7, 8, 9};

:height &amp;lt;&amp;lt; color cells({{"Red", a}, {"blue", b}, {"yellow", c}});
:weight &amp;lt;&amp;lt; color cells({{"Red", a}});
:age &amp;lt;&amp;lt; color cells({{"Red", a}, {"blue", b}});


get_colored_cells = Function({dt, colname}, {Default Local},
	colscript = Column(dt, colname) &amp;lt;&amp;lt; Get Script;
	l = Substitute(Name Expr(colscript), Expr(New Column()), List());
	colored_cells = {};
	Try(
		colors = l["Color Cells"];
		If(Type(colors[1]) == "List",
			jmptrickery = 1;
		,
			jmptrickery = 0;
		);
		For Each({color}, colors,
			If(jmptrickery,
				Insert Into(colored_cells, color[2]);
			,
				Insert Into(colored_cells, color);
			);
		);
	);
	return(Matrix(colored_cells));
);

colname = "age";
// for single column
rows = J(1, N Rows(dt), 0);
colored_rows = get_colored_cells(dt, colname);
rows[colored_rows] = 1;
dt &amp;lt;&amp;lt; New Column("result", Numeric, Nominal, Values(rows));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you can then create additional column to color each column when you loop over them&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 11:22:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/749287#M92967</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-24T11:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the row number of colored cells in a column and assign it a tag (say "1") in a newly created column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/750090#M93068</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Thanks. I have adapted your script to use with a dataset matching closely to mine. It works fine for one column name but not when I loop over column names.&amp;nbsp; Also, how do I place each newly created column beside (on the right of) the column on which the operation is performed within the loop?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Clear Log();

dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

col_names = dt &amp;lt;&amp;lt; Get Column Group( "Processes" );

ps = dt &amp;lt;&amp;lt; Process Screening(
	Process Variables( Eval( col_names ) ),
	Spec Limits Dialog( "No (skip columns with no spec limits)" ),
);

ps &amp;lt;&amp;lt; Color Out Of Spec Values (1);

t = ps &amp;lt;&amp;lt; Get Window Title; //Show( t );
ps &amp;lt;&amp;lt; Close Window;
dt &amp;lt;&amp;lt; Clear Select &amp;lt;&amp;lt; Clear Column Selection;

get_colored_cells = Function({dt, colname}, {Default Local},
	colscript = Column(dt, colname) &amp;lt;&amp;lt; Get Script;
	l = Substitute(Name Expr(colscript), Expr(New Column()), List());
	colored_cells = {};
	Try(
		colors = l["Color Cells"];
		If(Type(colors[1]) == "List",
			jmptrickery = 1;
		,
			jmptrickery = 0;
		);
		For Each({color}, colors,
			If(jmptrickery,
				Insert Into(colored_cells, color[2]);
			,
				Insert Into(colored_cells, color);
			);
		);
	);
	return(Matrix(colored_cells));
);

measColNames = dt &amp;lt;&amp;lt; get column names(Numeric,Continuous ); show (measColNames[1]);

For( i = 1, i &amp;lt;= N Items( measColNames), i++,
	rows = J( 1, N Rows( dt ), 0 );
	colored_rows = get_colored_cells( dt, measColNames[i]);
	rows[colored_rows] = 1;
	dt &amp;lt;&amp;lt; New Column( "PassFail"||measColNames[i], Numeric, Nominal, Values( rows ) );
);


//colname = "NPN1";
///// for single column
/*rows = J(1, N Rows(dt), 0);
colored_rows = get_colored_cells(dt, colname);
rows[colored_rows] = 1;
dt &amp;lt;&amp;lt; New Column("result", Numeric, Nominal, Values(rows));*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 10:28:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/750090#M93068</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2024-04-26T10:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the row number of colored cells in a column and assign it a tag (say "1") in a newly created column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/750091#M93069</link>
      <description>&lt;P&gt;Don't use For loop and use &amp;lt;&amp;lt; move selected columns to move your columns after your specified column&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

get_colored_cells = Function({dt, colname}, {Default Local},
	colscript = Column(dt, colname) &amp;lt;&amp;lt; Get Script;
	l = Substitute(Name Expr(colscript), Expr(New Column()), List());
	colored_cells = {};
	Try(
		colors = l["Color Cells"];
		If(Type(colors[1]) == "List",
			jmptrickery = 1,
			jmptrickery = 0
		);
		For Each({color}, colors,
			If(jmptrickery,
				Insert Into(colored_cells, color[2]),
				Insert Into(colored_cells, color)
			)
		);
	);
	Return(Matrix(colored_cells));
);

create_failed_column_after = function({dt, colname}, {Default Local},
	curname = Column(dt, colname) &amp;lt;&amp;lt; get name;

	failed_rows = get_colored_cells(dt, colname);
	row_vals = J(1, N Rows(dt), 0);
	row_vals[failed_rows] = 1;
	
	new_col = dt &amp;lt;&amp;lt; New Column((curname || "_FAIL"), Numeric, Nominal, Values(row_vals));	
	dt &amp;lt;&amp;lt; Move Selected Columns(new_col, After(Column(dt, colname)));
	
	return(new_col);
);


dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
col_names = dt &amp;lt;&amp;lt; Get Column Group("Processes");

dt &amp;lt;&amp;lt; show window(0);
wait(0);

ps = dt &amp;lt;&amp;lt; Process Screening(
	Process Variables(Eval(col_names)),
	Spec Limits Dialog("No (skip columns with no spec limits)")
);
ps &amp;lt;&amp;lt; Color Out Of Spec Values(1);
ps &amp;lt;&amp;lt; Close Window;
dt &amp;lt;&amp;lt; Clear Select &amp;lt;&amp;lt; Clear Column Selection;


For Each({colref}, col_names,
	colname = colref &amp;lt;&amp;lt; get name;
	create_failed_column_after(dt, colname);
);


dt &amp;lt;&amp;lt; show window(1);
wait(0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Fri, 26 Apr 2024 10:59:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/750091#M93069</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-26T10:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the row number of colored cells in a column and assign it a tag (say "1") in a newly created column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/774481#M95629</link>
      <description>&lt;P&gt;wow, great idea - via the column script!&lt;BR /&gt;&lt;BR /&gt;The cool thing about JMP:&lt;BR /&gt;The Workarounds : )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The not-so-cool thing in JMP:&lt;BR /&gt;The Workarounds for the workarounds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To directly get the out-of-spec values without the detour via Color, please vote:&amp;nbsp;&lt;LI-MESSAGE title="🙏 is in spec (value)" uid="774331" url="https://community.jmp.com/t5/JMP-Wish-List/is-in-spec-value/m-p/774331#U774331" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 05:24:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/774481#M95629</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-07-22T05:24:24Z</dc:date>
    </item>
  </channel>
</rss>

