<?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 Replace cell values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752606#M93417</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to replace all the failing cells in the attached data table, which is highlighted in red with &lt;STRONG&gt;1 &lt;/STRONG&gt;and passing cells with &lt;STRONG&gt;0.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jackie__0-1715089228220.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/63994iD34DC301B9C14E80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jackie__0-1715089228220.png" alt="Jackie__0-1715089228220.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Found this but something doesn't work-&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/How-do-you-get-the-color-of-a-specific-cell-in-a-data-table/td-p/10252" target="_self"&gt;How do you get the color of a specific cell in a data table using JSL?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any better way to replace the cell values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
cols = dt &amp;lt;&amp;lt; get column group( "Tests" );

get_cell_color = Function( {col, r}, 

	s = col &amp;lt;&amp;lt; get script;

     //Locate argument "Color Cells" in column script

	For( i = 1, i &amp;lt;= N Arg( s ), i++, 

		If( Head Name( Arg( s, i ) ) == "Color Cells", 

			p = i;

			Break();

		)

	);

     //Identify the sublist that contains the color of row r

	L = Arg( Arg( s, p ), 1 );

	For( i = 1, N Items( L ), i++, 

		If( N Row( Loc( L[i][2], r ) ) == 1, 

			color = L[i][1];

			Break();

		)

	);

	color;

);

// 


test_cols = Transform Each( {col}, cols, col &amp;lt;&amp;lt; get name );
dt &amp;lt;&amp;lt; Select All Rows;
selrow = dt &amp;lt;&amp;lt; get Selected Rows();
dt &amp;lt;&amp;lt; begin data update;

For Each( {testcol, idx}, test_cols, 

	For Each( {ro, idx2}, selrow, 
	
		
		cellcolor = get_cell_color( Column( testcol ), ro );
		If( !cellcolor == 3, 
		
			Column( testcol )[ro] = 0
		
		)

		;
	)
);
dt &amp;lt;&amp;lt; end data update;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2024 13:42:12 GMT</pubDate>
    <dc:creator>Jackie_</dc:creator>
    <dc:date>2024-05-07T13:42:12Z</dc:date>
    <item>
      <title>Replace cell values</title>
      <link>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752606#M93417</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to replace all the failing cells in the attached data table, which is highlighted in red with &lt;STRONG&gt;1 &lt;/STRONG&gt;and passing cells with &lt;STRONG&gt;0.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jackie__0-1715089228220.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/63994iD34DC301B9C14E80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jackie__0-1715089228220.png" alt="Jackie__0-1715089228220.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Found this but something doesn't work-&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/How-do-you-get-the-color-of-a-specific-cell-in-a-data-table/td-p/10252" target="_self"&gt;How do you get the color of a specific cell in a data table using JSL?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any better way to replace the cell values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
cols = dt &amp;lt;&amp;lt; get column group( "Tests" );

get_cell_color = Function( {col, r}, 

	s = col &amp;lt;&amp;lt; get script;

     //Locate argument "Color Cells" in column script

	For( i = 1, i &amp;lt;= N Arg( s ), i++, 

		If( Head Name( Arg( s, i ) ) == "Color Cells", 

			p = i;

			Break();

		)

	);

     //Identify the sublist that contains the color of row r

	L = Arg( Arg( s, p ), 1 );

	For( i = 1, N Items( L ), i++, 

		If( N Row( Loc( L[i][2], r ) ) == 1, 

			color = L[i][1];

			Break();

		)

	);

	color;

);

// 


test_cols = Transform Each( {col}, cols, col &amp;lt;&amp;lt; get name );
dt &amp;lt;&amp;lt; Select All Rows;
selrow = dt &amp;lt;&amp;lt; get Selected Rows();
dt &amp;lt;&amp;lt; begin data update;

For Each( {testcol, idx}, test_cols, 

	For Each( {ro, idx2}, selrow, 
	
		
		cellcolor = get_cell_color( Column( testcol ), ro );
		If( !cellcolor == 3, 
		
			Column( testcol )[ro] = 0
		
		)

		;
	)
);
dt &amp;lt;&amp;lt; end data update;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:42:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752606#M93417</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2024-05-07T13:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replace cell values</title>
      <link>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752617#M93418</link>
      <description>&lt;P&gt;&lt;LI-MESSAGE title="How to get the row number of colored cells in a column and assign it a tag (say &amp;amp;quot;1&amp;amp;quot;) in a newly created column?" uid="749264" url="https://community.jmp.com/t5/Discussions/How-to-get-the-row-number-of-colored-cells-in-a-column-and/m-p/749264#U749264" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;might provide other suggestion. With small modification to&amp;nbsp;&lt;EM&gt;create_failed_column_after&lt;/EM&gt; (you should also rename it) you can get it to update the values instead of creating new column with the values.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:49:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752617#M93418</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-07T13:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Replace cell values</title>
      <link>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752671#M93425</link>
      <description>&lt;P&gt;This is one way how you could modify the script found from that post&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));
);

colored_to_pass_fail = function({dt, colname}, {Default Local},
	failed_rows = get_colored_cells(dt, colname);
	row_vals = J(1, N Rows(dt), 0);
	row_vals[failed_rows] = 1;

	Column(dt, colname) &amp;lt;&amp;lt; set values(row_vals);
	// dt[0, colname] = row_vals`; // or data table subscripting
);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

wait(1);
dt &amp;lt;&amp;lt; Select Rows([4,5,6,7, 10,11, 14, 15]);
:height &amp;lt;&amp;lt; Color Cells(3);
dt &amp;lt;&amp;lt; clear select;
wait(1);


dt &amp;lt;&amp;lt; Begin Data Update;
For Each({colname}, dt &amp;lt;&amp;lt; Get Column Names("String", Continuous),
	colored_to_pass_fail(dt, colname);
);
dt &amp;lt;&amp;lt; End Data Update;

wait(0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 07 May 2024 15:39:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752671#M93425</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-07T15:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replace cell values</title>
      <link>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752719#M93432</link>
      <description>&lt;P&gt;Thank Jarmo&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 17:06:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Replace-cell-values/m-p/752719#M93432</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2024-05-07T17:06:30Z</dc:date>
    </item>
  </channel>
</rss>

