<?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 Conditional Formatting Columns in a Table Box in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39929#M23381</link>
    <description>&lt;P&gt;Hi - I want to apply a single conditional formatting rule to two columns of data in a Table Box. I've set up below an example using the Big Class data set which illustrates the problem, in which I can easily do what I want within a data table, but producing the same effect within a Table Box seems to be a bit more tricky.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The mechanism for creating the conditional format for a column of a Table Box is completely different to that needed for a data table, and requires that I set up a rule within my Preferences as shown. This part is straightforward enough, but I can't see a way then to apply that rule to a column other than the one to which the rule directly relates. &amp;nbsp;Can it be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// Color-code blue all pupils whose height is at least 60, with everybody else purple;

// First color every cell in both the name and height columns purple;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );

// Now find everybody whose height is at least 60, and color them blue;

CellsToPaint = dt &amp;lt;&amp;lt; get rows where( :Height &amp;gt;= 60 );

Show( CellsToPaint );

// Color them all blue;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );

// Now I'll try to produce the same effect with those two columns in a table box;

// Create a copy of the Big Class data table in a table box;

My_TB = Table Box( &amp;lt;&amp;lt;Set Shade Alternate Rows( 1 ), &amp;lt;&amp;lt;Set Shade Headings( 0 ), &amp;lt;&amp;lt;Set Column Borders( 1 ), &amp;lt;&amp;lt;Border( 1 ) );

For( i = 1, i &amp;lt;= N Col( dt ), i++,
	Heading = Column( dt, i ) &amp;lt;&amp;lt; get name;
	Contents = Column( dt, i ) &amp;lt;&amp;lt; get values;
	If( (Column( dt, i ) &amp;lt;&amp;lt; get data type) == "Numeric",
		My_TB &amp;lt;&amp;lt; append( Number Col Box( Heading, Contents ) ),
		My_TB &amp;lt;&amp;lt; append( String Col Box( Heading, Contents ) )
	);
);

// Create a conditional formatting rule called "Tall";

Preferences(
	Conditional Formatting Rules(
		RuleSet(
			RuleName( "Tall" ),
			GreaterThan( Value( 60 ), Inclusive( 1 ), Format( Back Color( {100, 100, 255} ) ) ),
			LessThan( Value( 60 ), Inclusive( 0 ), Format( Back Color( {255, 0, 255} ) ) )
		)
	)
);

// Make sure it's been included in the Preferences;
	
Show Preferences();

// Apply my newly-created "Tall" rule to the Height column;

My_TB[4] &amp;lt;&amp;lt; set conditional format( "Tall" );

// And finally show the result of applying it;

New Window( "My Window", My_TB );
	
// But can I apply that same color scheme to the "Name" column as well?  If so, how?

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Jun 2017 10:46:36 GMT</pubDate>
    <dc:creator>DMR</dc:creator>
    <dc:date>2017-06-04T10:46:36Z</dc:date>
    <item>
      <title>Conditional Formatting Columns in a Table Box</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39929#M23381</link>
      <description>&lt;P&gt;Hi - I want to apply a single conditional formatting rule to two columns of data in a Table Box. I've set up below an example using the Big Class data set which illustrates the problem, in which I can easily do what I want within a data table, but producing the same effect within a Table Box seems to be a bit more tricky.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The mechanism for creating the conditional format for a column of a Table Box is completely different to that needed for a data table, and requires that I set up a rule within my Preferences as shown. This part is straightforward enough, but I can't see a way then to apply that rule to a column other than the one to which the rule directly relates. &amp;nbsp;Can it be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// Color-code blue all pupils whose height is at least 60, with everybody else purple;

// First color every cell in both the name and height columns purple;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );

// Now find everybody whose height is at least 60, and color them blue;

CellsToPaint = dt &amp;lt;&amp;lt; get rows where( :Height &amp;gt;= 60 );

Show( CellsToPaint );

// Color them all blue;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );

// Now I'll try to produce the same effect with those two columns in a table box;

// Create a copy of the Big Class data table in a table box;

My_TB = Table Box( &amp;lt;&amp;lt;Set Shade Alternate Rows( 1 ), &amp;lt;&amp;lt;Set Shade Headings( 0 ), &amp;lt;&amp;lt;Set Column Borders( 1 ), &amp;lt;&amp;lt;Border( 1 ) );

For( i = 1, i &amp;lt;= N Col( dt ), i++,
	Heading = Column( dt, i ) &amp;lt;&amp;lt; get name;
	Contents = Column( dt, i ) &amp;lt;&amp;lt; get values;
	If( (Column( dt, i ) &amp;lt;&amp;lt; get data type) == "Numeric",
		My_TB &amp;lt;&amp;lt; append( Number Col Box( Heading, Contents ) ),
		My_TB &amp;lt;&amp;lt; append( String Col Box( Heading, Contents ) )
	);
);

// Create a conditional formatting rule called "Tall";

Preferences(
	Conditional Formatting Rules(
		RuleSet(
			RuleName( "Tall" ),
			GreaterThan( Value( 60 ), Inclusive( 1 ), Format( Back Color( {100, 100, 255} ) ) ),
			LessThan( Value( 60 ), Inclusive( 0 ), Format( Back Color( {255, 0, 255} ) ) )
		)
	)
);

// Make sure it's been included in the Preferences;
	
Show Preferences();

// Apply my newly-created "Tall" rule to the Height column;

My_TB[4] &amp;lt;&amp;lt; set conditional format( "Tall" );

// And finally show the result of applying it;

New Window( "My Window", My_TB );
	
// But can I apply that same color scheme to the "Name" column as well?  If so, how?

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 10:46:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39929#M23381</guid>
      <dc:creator>DMR</dc:creator>
      <dc:date>2017-06-04T10:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting Columns in a Table Box</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39932#M23383</link>
      <description>&lt;P&gt;I do not have a solution that will create a Conditional Formatting Rule. &amp;nbsp;However, I have accomplished what you want, by moving the colored data table into a journal, and then appending TableBox(1) from that journal into the application that I am creating&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="color journal.PNG" style="width: 302px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/6330iBFA0DE19403E49AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="color journal.PNG" alt="color journal.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 13:14:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39932#M23383</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-04T13:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting Columns in a Table Box</title>
      <link>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39933#M23384</link>
      <description>&lt;P&gt;Many thanks Jim - that's ingenious!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just for the record, I'm adding below a copy of a modified version of my original script which incorporates your recommendation as to how to resolve this. &amp;nbsp;Thanks once again - this is going to be phenomenally useful to me.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Log();

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// Color-code blue all pupils whose height is at least 60, with everybody else purple;

// First color every cell in both the name and height columns purple;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 255, 0, 255 ), Index( 1, N Row( dt ) ) );

// Now find everybody whose height is at least 60, and color them blue;

CellsToPaint = dt &amp;lt;&amp;lt; get rows where( :Height &amp;gt;= 60 );

Show( CellsToPaint );

// Color them all blue;

Column( dt, "name" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );
Column( dt, "height" ) &amp;lt;&amp;lt; color cells( RGB Color( 100, 100, 255 ), CellsToPaint );

// Now I'll produce the same effect with those two columns in a table box using Jim's suggestion;

// Export it to the journal as a data table, which converts it into a TableBox in the process;

dt &amp;lt;&amp;lt; journal;

// Pull it back again as a TableBox, putting into a window with any other objects that I might want to incorporate;

nw = New Window( "My Window",
	Lineup Box( N Col( 1 ),
		Text Box( "Clever, huh?" ),
		Border Box( Current Journal()[Table Box( 1 )], &amp;lt;&amp;lt;sides( 15 ), &amp;lt;&amp;lt;background color( {0.8, 0.8, 1} ) ),
		&amp;lt;&amp;lt;padding( 10 )
	)
);

// Now I've got a copy of it in the window I can throw away the journal;
	
Close All( journals );

// And I can inspect its properties - and modify them if I want to - by just referencing nw[TableBox(1)];

Show Properties( nw[Table Box( 1 )] );

// Tidy it up a bit for the final display;

nw[Table Box( 1 )] &amp;lt;&amp;lt; Set Shade Alternate Rows( 1 );
nw[Table Box( 1 )] &amp;lt;&amp;lt; Set Shade Headings( 0 );
nw[Table Box( 1 )] &amp;lt;&amp;lt; Set Column Borders( 1 );
nw[Table Box( 1 )] &amp;lt;&amp;lt; Border( 1 );

// End of script;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 14:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Conditional-Formatting-Columns-in-a-Table-Box/m-p/39933#M23384</guid>
      <dc:creator>DMR</dc:creator>
      <dc:date>2017-06-04T14:24:38Z</dc:date>
    </item>
  </channel>
</rss>

