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
- :
- Row State select and color

- 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 13, 2018 3:49 PM
(3209 views)

Okay I've tried various things to try and get this to work, but all I've got so far is a not quite functionally useable script. The deletion script works beautifully, but while the row state script -works- it doesn't quite work the way I want it to, and I'm hoping there's a way to clean it up a bit.

```
dt << New Column ( "Row State 1",
Row State,
Set Formula ( If( :Alarm ID == "'00000D06", Color State(70))),
);
dt << New Column ( "Row State 2",
Row State,
Set Formula ( If( :Alarm ID == ("'000000B2"| "'000000BE"| "'0000013C"| "'0000013D"),
Color State(6))),
);
dt << New Column ( "Row State 3",
Row State,
Set Formula ( If( :Alarm ID == ("'0000000E"| "'00000144"| "'0000000A"| "'00000021"|
"'00000025"| "'00000027"| "'000000E9"| "'00000145"| "'000001E1"| "'00000F7C"),
Color State(1))),
);
dt << New Column ( "Row State 4",
Row State,
Set Formula ( If( :Alarm ID == "'00000E6E", Color State(38))),
);
dt << New Column ( "Row State 5",
Row State,
Set Formula ( If( :Alarm ID == ("'00000D3B"| "'00000230"| "'00000D42"), Color State(73))),
);
dt << New Column ( "Row State 6",
Row State,
Set Formula ( If( :Alarm ID == ("'0000003B"| "'00000072"| "'00000E8C"), Color State(37))),
);
dt << New Column ( "Row State 7",
Row State,
Set Formula ( If( :Alarm ID == "'00000DB6", Color State(78))),
);
dt << New Column ( "Row State 8",
Row State,
Set Formula ( If( :Alarm ID == "'00000E99", Color State(75))),
);
dt << New Column ( "Row State 9",
Row State,
Set Formula ( If( :Alarm ID == ("'00000E68"| "'00000E71"| "'00000E72"| "'00000E9A"),
Color State(72))),
);
dt << New Column ( "Row State 10",
Row State,
Set Formula ( If( :Alarm ID == ("'0000004E"| "'0000005C"| "'0000011C"| "'00000143"|
"'00000148"| "'000001D9"| "'00000DE9"| "'00000E41"), Color State(12))),
);
dt << New Column ( "Row State 11",
Row State,
Set Formula ( If( :Alarm ID == "'00000D2F", Color State(19))),
);
dt << New Column ( "Row State 12",
Row State,
Set Formula ( If( :Alarm ID == "'00000D2D", Color State(28))),
);
```

Basically, select row containing specific value in column Alarm ID and set the row state to the color selected. What I -want- it to do, is set the row state and highlight the row the color of the row state, presumably I can do that with an append after all the row states are set.

What this does, it creates a row state but doesn't apply it, I have to apply it manually, also it creates an individual row state for each line, which gets cluttered quickly, I suspect I may be able to use the else to at least remove lines that are not present, which would help. It also appears that the lines with multiple options is not actually working, I was hoping I could get that to work so I wouldn't have to make 1 line per code.

Hopefully someone can help me out, still plugging away at it when I get time, thanks!

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

I think this would work for you. This assumes you don't have a color state already and that none of your items overlap.

```
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
color_aa = associative array(
{
// list of values are the first item, color state is the second in each list.
{{12, 13, 16}, 3},
{{14, 15}, 4},
{{17}, 5}
}
);
dt << Select Rows([1, 5, 9]);
rs = dt << Get Row States;
for(values = color_aa << First, !isempty(values), values = color_aa << Next(values),
rows = dt << Get Rows Where(Contains(values, :age));
color = color_aa[values];
rs[rows] = rs[rows] + 2^8*color;
);
dt << Set Row States(rs);
```

Vince Faller - Predictum

5 REPLIES 5

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

Re: Row State select and color

I might not be understanding your question correctly. But here's my best guess at it. First off, I've never been about to get your formula working. You can't do "something" == ("stuff"|"something") and have it evaluate true. At least to my knowledge. I made an example of what I think you're trying to do, but I could be way off.

```
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
// this doesn't work
dt << New Column("Test", formula(:age == (12 | 14 | 16)));
//this should
values = {12, 14, 16};
rows = dt << Get Rows Where(Contains(values, :age));
//assuming they don't have color
dt << Select Rows([1, 5, 9]);
wait(1);
rs = dt << Get Row States;
//2^8*3 = color state(3) = red
rs[rows] = rs[rows] + 2^8*3;
dt << Set Row States(rs);
```

Vince Faller - Predictum

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

Re: Row State select and color

clearly I can't get my formula to work either ^.^

Simply put, I want Row with X value highlighted one color

Row with Y and Z value highlighted another color

etc...

specific colors are in the script already, apparently the | or argument is the problem in selecting those, I'm just not sure the right way to express it.

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

Re: Row State select and color

If you want to change the Color State for each of the rows, based upon your selections, the below partial script is for structure you want to use to make the changes

```
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Rows( dt ), i++,
If(
N Rows( Loc( {"'00000D06"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 70 ),
N Rows( Loc( {"'000000B2", "'000000BE", "'0000013C", "'0000013D"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 6 ),
N Rows(
Loc(
{"'0000000E", "'00000144", "'0000000A", "'00000021", "'00000025", "'00000027", "'000000E9", "'00000145", "'000001E1", "'00000F7C"},
:Alarm ID[i]
)
) > 0, Row State( i ) = Color State( 1 ),
N Rows( Loc( {"'00000E6E"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 38 ),
N Rows( Loc( {"'00000D3B", "'00000230", "'00000D42"}, :Alarm ID[i] ) ) > 0, Row State( i ) = Color State( 73 )
)
);
```

Jim

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

I think this would work for you. This assumes you don't have a color state already and that none of your items overlap.

```
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
color_aa = associative array(
{
// list of values are the first item, color state is the second in each list.
{{12, 13, 16}, 3},
{{14, 15}, 4},
{{17}, 5}
}
);
dt << Select Rows([1, 5, 9]);
rs = dt << Get Row States;
for(values = color_aa << First, !isempty(values), values = color_aa << Next(values),
rows = dt << Get Rows Where(Contains(values, :age));
color = color_aa[values];
rs[rows] = rs[rows] + 2^8*color;
);
dt << Set Row States(rs);
```

Vince Faller - Predictum

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

Re: Row State select and color

This one works beautifully, thanks! One of the beauties of this system (and sometimes curses) is there's multiple different ways to tackle the same problem. The next one shall be quite challenging, I'll probably try and tackle it next week lol (or it could be very simple and I just don't know yet!)