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

- JMP User Community
- :
- Discussions
- :
- Using an OR statement in selecting rows for exclusion

- 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

Sep 1, 2020 4:15 PM
(214 views)

I am a JSL newbie ...

I want to select rows and then hide and exclude based on two criteria using an OR statement. I want to select when 'comment' is blank or when Excluded Sum < 2. I can get both conditions to work independently but when I combine them with an OR statement, no rows are selected. I have also tried current selection ("extend") with the same result. I am using JMP 15.2.0

```
dt =Current Data Table();
dt <<Clear Row States();
dt << select where(:comment == "" | :Excluded Sum < 2);
dt << invert row selection;
dt << exclude;
dt << hide;
```

Thank you for any thoughts on this.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

I think rewriting the logic so the InvertRowSelection isn't needed might help make the intent clear. I'm guessing you might really mean something like this

```
dt =Current Data Table();
dt <<Clear Row States();
dt << select where(
:comment != "" // exclude if there is a comment
| // or
:Excluded Sum >= 2 // if there are too many excluded
);
//dt << invert row selection; // leave this out, it makes the logic hard to follow
dt << exclude;
dt << hide;
```

Craige

6 REPLIES 6

Highlighted
##

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

Re: Using an OR statement in selecting rows for exclusion

My test case works great, using your code.

```
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 10 ),
New Column( "Comment",
Character,
"Nominal",
Set Values(
{"not blank", "not blank", "", "not blank", "", "not blank", "not blank",
"", "not blank", "not blank"}
),
Set Display Width( 89 )
),
New Column( "Excluded Sum",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [5, 1, 51, 44, 6, 0, 7, 1.5, 9, -5] )
)
);
dt << Clear Row States();
dt << select where( :comment == "" | :Excluded Sum < 2 );
dt << invert row selection;
dt << exclude;
dt << hide;
```

Jim

Highlighted
##

@txnelson I still can't get the script to work on my data set. I've trimmed it down and attached it with the script to this post. I'm afraid I'm missing something obvious here. Thanks.

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

Re: Using an OR statement in selecting rows for exclusion

Highlighted
##

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

Re: Using an OR statement in selecting rows for exclusion

The data table you provided has no rows that do not meet the criteria for you Select Where. Every row has either an Excluded value less than 2 or a Comment that is blank, or both. Every row that has a Comment, has an Excluded Sum of 1, which is less than 2. So given your code, no rows will end up hidden and excluded.

Jim

Highlighted

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

I think rewriting the logic so the InvertRowSelection isn't needed might help make the intent clear. I'm guessing you might really mean something like this

```
dt =Current Data Table();
dt <<Clear Row States();
dt << select where(
:comment != "" // exclude if there is a comment
| // or
:Excluded Sum >= 2 // if there are too many excluded
);
//dt << invert row selection; // leave this out, it makes the logic hard to follow
dt << exclude;
dt << hide;
```

Craige

Highlighted
##

@Craige_Hales That works perfectly! I need to brush up on my logic skills as well as learning JSL. Thank you.

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

Re: Using an OR statement in selecting rows for exclusion

Highlighted
##

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

Re: Using an OR statement in selecting rows for exclusion

@txnelsonI was afraid of that - it seems my logic is rusty. Thanks.