cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

Transferring color

 

Hello,

 

I am building my knowledge of JMP and now find myself with a color problem.  I would like to transfer the color of each row from the Mean (Meeting Yield Target) cell to the Mean (Yield) cell in each row.  Is it possible to do this with a formula?  My scripting knowledge is limited to simple automation based upon code extracted from the log window.  If you have any simple ideas please share them.

 

Thank you.

 

FullSpectrum255_0-1688061876863.png

1 ACCEPTED SOLUTION

Accepted Solutions
StarfruitBob
Level VI

Re: Transferring color

Hello @FullSpectrum255 ,

 

At this time, there doesn't seem to be a way to detect the color of a cell, only to color or clear the color of a cell.

 

An alternative might be to create a formula that colors the Mean(Yield) cells based upon the value of the Mean(Meets Yield Target) values. Interestingly, when I tried this approach either the numbers were fully erased, or only row 1 would be colored. I wonder if anyone else has tips to make the formula route work, because it's a better solution.

 

A slightly different approach that is a bit more work, long term, is just to script an if statement to color each cell according to the Mean(Meets Yield Target) values.  Examples below.

 

Names default to here(1);

dt = current data table();

// Works, but you'll need to run the script every time you want the cells colored
for( i = 1, i <= N rows(dt), i++,
	if(
		:"Mean(Meets Yield Target)"n[i] == 1, :"Mean(Yield)"n << Color Cells( "Green", i ),
		:"Mean(Meets Yield Target)"n[i] == 0, :"Mean(Yield)"n << Color Cells( "Yellow", i ),
		:"Mean(Meets Yield Target)"n[i] == -1, :"Mean(Yield)"n << Color Cells( "Red", i ),
	)	
);

/* Better solution, if if was fixed
dt:"Mean(Yield)"n << Set formula(
	if(
		:"Mean(Meets Yield Target)"n == 1, :"Mean(Yield)"n << Color Cells( "Green", row() ),
		:"Mean(Meets Yield Target)"n == 0, :"Mean(Yield)"n << Color Cells( "Yellow", row() ),
		:"Mean(Meets Yield Target)"n == -1, :"Mean(Yield)"n << Color Cells( "Red", row() ),
	)
);
*/
Learning every day!

View solution in original post

3 REPLIES 3
StarfruitBob
Level VI

Re: Transferring color

Hello @FullSpectrum255 ,

 

At this time, there doesn't seem to be a way to detect the color of a cell, only to color or clear the color of a cell.

 

An alternative might be to create a formula that colors the Mean(Yield) cells based upon the value of the Mean(Meets Yield Target) values. Interestingly, when I tried this approach either the numbers were fully erased, or only row 1 would be colored. I wonder if anyone else has tips to make the formula route work, because it's a better solution.

 

A slightly different approach that is a bit more work, long term, is just to script an if statement to color each cell according to the Mean(Meets Yield Target) values.  Examples below.

 

Names default to here(1);

dt = current data table();

// Works, but you'll need to run the script every time you want the cells colored
for( i = 1, i <= N rows(dt), i++,
	if(
		:"Mean(Meets Yield Target)"n[i] == 1, :"Mean(Yield)"n << Color Cells( "Green", i ),
		:"Mean(Meets Yield Target)"n[i] == 0, :"Mean(Yield)"n << Color Cells( "Yellow", i ),
		:"Mean(Meets Yield Target)"n[i] == -1, :"Mean(Yield)"n << Color Cells( "Red", i ),
	)	
);

/* Better solution, if if was fixed
dt:"Mean(Yield)"n << Set formula(
	if(
		:"Mean(Meets Yield Target)"n == 1, :"Mean(Yield)"n << Color Cells( "Green", row() ),
		:"Mean(Meets Yield Target)"n == 0, :"Mean(Yield)"n << Color Cells( "Yellow", row() ),
		:"Mean(Meets Yield Target)"n == -1, :"Mean(Yield)"n << Color Cells( "Red", row() ),
	)
);
*/
Learning every day!
StarfruitBob
Level VI

Re: Transferring color

On a side note, the Scripting Index is a fantastic resource to brows through documented functions! A quick search for keywords usually helps narrow down the available functions that can be used for your task.

StarfruitBob_0-1688066432181.png

StarfruitBob_1-1688066508482.png

 

 

Learning every day!

Re: Transferring color

Thank you StarfruitBob.  The script applies the same color coding by value perfectly.  110% better than highlighting them with red boxes by hand in powerpoint.

 

Thanks 1e6.