cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
dn610
Level III

JMP Scripting Coloring Cells Based on a Criteria

Hi - Can someone please tell me how I would go about coloring a cell that is not equal to 1 in the summary sheet below using JMP Scripting, starting with the N Categories (Process Taxonomy Level 1) column? Also, these are just sample columns, there are 40 other columns so I don't want to specify the actual column names in the script. Lastly, If a cell is colored in the summary table, can the color be applied to the original data table, to which the summary table is linked?

 

dn610_0-1646152790711.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JMP Scripting Coloring Cells Based on a Criteria

Here is one way to handle the issue:

txnelson_0-1646156136944.png

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );

 dtSum = dt << Summary(
	Group( :age ),
	Mean( :height ),
	Mean( :weight ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);

// Get the column names of the current columns
sumColNames = dtSum << get column names(string);

// Remove the first 2 columns from the list
remove from( sumColNames, 1, 2 );

// loop across columns finding all cells > 63
For( i=1, i<= N Items( sumColNames ), i++,
	// select all rows where cells are above 63
	dtSum << select where( as column( dtSum, sumColNames[i]) > 63 );
	
	// Color cells in summary table
	as column(dtSum, sumColNames[i]) << Color Cells( red, dtSum << get selected rows );
	// Color cells in original table
	as column(dt, sumColNames[i]) << Color Cells( red, dt << get selected rows );
)

 

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: JMP Scripting Coloring Cells Based on a Criteria

Here is one way to handle the issue:

txnelson_0-1646156136944.png

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );

 dtSum = dt << Summary(
	Group( :age ),
	Mean( :height ),
	Mean( :weight ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);

// Get the column names of the current columns
sumColNames = dtSum << get column names(string);

// Remove the first 2 columns from the list
remove from( sumColNames, 1, 2 );

// loop across columns finding all cells > 63
For( i=1, i<= N Items( sumColNames ), i++,
	// select all rows where cells are above 63
	dtSum << select where( as column( dtSum, sumColNames[i]) > 63 );
	
	// Color cells in summary table
	as column(dtSum, sumColNames[i]) << Color Cells( red, dtSum << get selected rows );
	// Color cells in original table
	as column(dt, sumColNames[i]) << Color Cells( red, dt << get selected rows );
)

 

Jim
dn610
Level III

Re: JMP Scripting Coloring Cells Based on a Criteria

Thank you so much! It worked. 

 

As a follow up question, if I wanted to create an indicator column with a 1 to mark any row with a highlighted cell in the data table, how can I do that?

txnelson
Super User

Re: JMP Scripting Coloring Cells Based on a Criteria

  1. Read the documents, Discovering JMP and Using JMP.  Both documents are in the JMP Documentation Library available under the Help pull down menu.
  2. To add an indicator column
    1. Create a new column in both the original data table, and in the summary data table.  Call the column "Flag" or "Indicator" etc.
    2. Add to the script, as the last 2 lines in the For() loop
      dt:Flag[dt << get selected rows]=1;
      dtSum:Flag[dtSum << get selected rows]=1;

       

  3. Take the time to study the script to make sure you understand it.
Jim
dn610
Level III

Re: JMP Scripting Coloring Cells Based on a Criteria

Thank you so much!