Choose Language Hide Translation Bar
Highlighted

## Keeping cell color when split tabels

Hi,

I used example Sample 49836 to color cells in one column by the value in a different column, but now i need to split the table and keep the cell colors.

I saw a previous discussion regarding concatenated table, with some work around how to get the colors again.

Is there a similar way to do it with split table?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Keeping cell color when split tabels

Here is an extension of the sample you referenced that might give you some hint on how to transfer the colors

``````/* Open a sample data table */
dt = Open( "\$SAMPLE_DATA/Big Class.jmp" );

/* Obtain a list of unique values of age */
Summarize( a = By( :age ) );

/* Assign rowstate colors by the values in the age column */
dt << Color by Column( :age, Color Theme( "JMP Dark" ) );

/* Loop through each unique age and assign the rowstate color to the Color Cells */
For( i = 1, i <= N Items( a ), i++,
r = As List( dt << Get Rows Where( :age == Num( a[i] ) ) );
Column( dt, "height" ) << Color Cells( Color Of( Row State( r ) ), r );
);

dtSplit = dt << Split( Split By( :age ), Split( :height ), Remaining Columns( Drop All ), Sort by Column Property );

// loop across all of the columns, and color the non missing cells with the
// color they had in the original data table
For( i = 1, i <= N Cols( dtSplit ), i++,

// Create a row list from the original table, based upon the column name
// in the split data table
r = As List( dt << Get Rows Where( :age == Num( Column( dtSplit, i ) << get name ) ) );

// Create a list of non missing rows in the split data table
r1 = As List( dtSplit << Get Rows Where( Is Missing( Column( dtSplit, i )[Row()] ) == 0 ) );

// Point back to the original data table and get the color from the row state
Current Data Table( dt );
TheColor = Color Of( Row State( r ) );

// Point to the split table, and set the color of all of the
// non missing cells to the color found in the original table
Current Data Table( dtSplit );
Column( dtSplit, i ) << Color Cells( TheColor, r1 );
);``````
Jim
7 REPLIES 7
Highlighted

## Re: Keeping cell color when split tabels

Please excuse my ignorance, but where can I find  "Sample 49836 to color cells in one column by the value in a different column".

There is not a direct way to keep the cell colors, but if I can see the specifics of the sample you are referencing, I may be able to fashion a solution.

Jim
Highlighted  Jeff_Perkinson Community Manager

## Re: Keeping cell color when split tabels

I think the OP is referring to this support note.

-Jeff
Highlighted

## Re: Keeping cell color when split tabels

This is the one, I'm sorry i haven't put the link on my first post.
after the split I get many continuous columns without any color.
The strange thing I noticed is when I split colored Character column, I do get colors but not the correct ones..
If the colors where correct, I could have change the column to Charecter, split and then change back to Continues, but anyway it's not an elegant solution.

Thanks Again

Highlighted

## Re: Keeping cell color when split tabels

Here is an extension of the sample you referenced that might give you some hint on how to transfer the colors

``````/* Open a sample data table */
dt = Open( "\$SAMPLE_DATA/Big Class.jmp" );

/* Obtain a list of unique values of age */
Summarize( a = By( :age ) );

/* Assign rowstate colors by the values in the age column */
dt << Color by Column( :age, Color Theme( "JMP Dark" ) );

/* Loop through each unique age and assign the rowstate color to the Color Cells */
For( i = 1, i <= N Items( a ), i++,
r = As List( dt << Get Rows Where( :age == Num( a[i] ) ) );
Column( dt, "height" ) << Color Cells( Color Of( Row State( r ) ), r );
);

dtSplit = dt << Split( Split By( :age ), Split( :height ), Remaining Columns( Drop All ), Sort by Column Property );

// loop across all of the columns, and color the non missing cells with the
// color they had in the original data table
For( i = 1, i <= N Cols( dtSplit ), i++,

// Create a row list from the original table, based upon the column name
// in the split data table
r = As List( dt << Get Rows Where( :age == Num( Column( dtSplit, i ) << get name ) ) );

// Create a list of non missing rows in the split data table
r1 = As List( dtSplit << Get Rows Where( Is Missing( Column( dtSplit, i )[Row()] ) == 0 ) );

// Point back to the original data table and get the color from the row state
Current Data Table( dt );
TheColor = Color Of( Row State( r ) );

// Point to the split table, and set the color of all of the
// non missing cells to the color found in the original table
Current Data Table( dtSplit );
Column( dtSplit, i ) << Color Cells( TheColor, r1 );
);``````
Jim
Highlighted

## Re: Keeping cell color when split tabels

Thanks for the quick response,

The problem is that I need to split the table by other column then the column used for setting the color by.

in our example, I need to split the table by :sex while the color is defined by :age.

dtSplit = dt << Split( Split By( :sex ), Split( :height ), Remaining Columns( Drop All ), Sort by Column Property );

Thanks Again,

Ran

Highlighted

## Re: Keeping cell color when split tabels

I was aware that you had not given the precise information on what your split is.  My intension of providing the example I generated, was to give to you an example of the general approach that would have to be taken to solve the issue.  I assume that you should be able to take the example I gave and expand and change it to meet your precise specifications.

Jim
Highlighted