Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Select Cell Color for Row Based on one Cell's Value

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 5, 2018 11:07 AM
(2320 views)

Hello JMP Discussions. I think this is an easy one but everything I have researched and everything I have tried has failed.

Is it possible to color all cells in a row based on the value found in a column of that row? I want to select a color that is readable for selected row and leave ones that don't fit the criteria with default color. If I use Color Rows by Row State the data is not readable using the default color scheme. I need a table that will highlight the entire row when criteria is met. Ex. If Col_1 = 1 then color all of the cells in this row (Col_2, Col_3, Col_4, etc.) a light blue, otherwise, do nothing.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

You have to color cell by cell. Try this code:

```
dt = New Table( "test", Add Rows( 6 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [0, 1, 1, 0, 1, 0] ) ),
New Column( "Column 2", Character, "Nominal",
Set Values( {"A", "B", "C", "D", "E", "F"} ) ),
New Column( "Column 3", Character, "Nominal",
Set Values( {"G", "H", "I", "J", "K", "L"} ) )
);
// Make the rows light gray
light_gray = rgb color(200, 200, 200);
my_rows = dt << get rows where(:Column 1 == 1);
my_row_list = as list(my_rows);
column_list = dt << get column names(String);
for (i = 1, i <= nitems(column_list), i++,
column(dt, column_list[i]) << color cells(light_gray, my_row_list);
);
```

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

try this:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Color by Column( :Age );
Wait( 2 );
dt << Color Rows by Row State;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

perhaps try setting the colors manualy as such

```
:age << Set Property(
"Value Colors", // assign the value colors
{12 = Red, 13 = Yellow, 14 = Green, 15 = Blue, 16 = Magenta, 17 =
Gray}
);
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

@ron_horne, Thanks for trying to help me out. However, I feel that I am not being clear. What I'm looking for is the following based on the value in :RowColor

I want the whole row for RowColor = 1 to be light blue/Color(59)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

```
dt << Select Rows( dt << Get Rows Where( :RowColor == 1 ) );
Rws = dt << Get Selected Rows;
Rws = AsList(Rws);
dt << Color Cells( Color(59), Rws );
```

Just tried this and the rows are selected but I cannot change the color of any cells using this code. Trying to discover what step I'm missing as this is the logic I would follow to color the cells manually.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

You have to color cell by cell. Try this code:

```
dt = New Table( "test", Add Rows( 6 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [0, 1, 1, 0, 1, 0] ) ),
New Column( "Column 2", Character, "Nominal",
Set Values( {"A", "B", "C", "D", "E", "F"} ) ),
New Column( "Column 3", Character, "Nominal",
Set Values( {"G", "H", "I", "J", "K", "L"} ) )
);
// Make the rows light gray
light_gray = rgb color(200, 200, 200);
my_rows = dt << get rows where(:Column 1 == 1);
my_row_list = as list(my_rows);
column_list = dt << get column names(String);
for (i = 1, i <= nitems(column_list), i++,
column(dt, column_list[i]) << color cells(light_gray, my_row_list);
);
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Select Cell Color for Row Based on one Cell's Value

Thank you @pmroz!!! That is what I had missed! All the other "For" statements I attempted previously didn't get me there. Now I see where I went wrong.

THANK YOU, THANK YOU!