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 where using several conditions

- 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 15, 2017 10:51 AM
(4212 views)

Hello,

I am struggeling with selecting several rows according to some specific values. I want to select rows where a column cell contains specific values. I manage to select according to two columns with specific values but I cannot add values from the same column that should also be taken into consideration for row selection.

My code that works looks like this:

dt=Current Data Table ();

dt<< select where (:stationsnamn=="Jungfrun NV" & :profildjup >= 14 &:profildjup <= 16);

However, I want to be able to select for example:

dt=Current Data Table ();

dt<< select where (:stationsnamn=="Jungfrun NV" & :profildjup == 1 &:profildjup==14 &:profildjup == 31);

I understand that .jmp understands the latter as all three numbers have to be present in the same cell. How can I select those rows where in column "profildjup" cells contain 1 Or 14 Or 31 for the specific column stationname?

Furthermore, how could I add a "select labelled" o this command? Select labelled would refer to additional rows not specified by the information given above.

All help is very appreciated.

2 ACCEPTED SOLUTIONS

Accepted Solutions

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

For your select statement:

`dt << Select Where( :Sepal length == 6.7 & :Sepal length == 6.8);`

You need to use the OR operator (|), not AND (&):

`dt << Select Where( :Sepal length == 6.7 | :Sepal length == 6.8);`

(edit - need to use == for equals comparison, not =)

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

@Pacco,

There are many ways to do this . One of the ways is to leverage the "extend" functionality. The second argument lets you either "extend" / "restrict" / "clear" current selection . So you can do something like this :

```
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Rows( [5, 7, 8, 10, 15] ); // For demo purpose only
dt << Label( 1 );
dt << Clear Select;
Wait( 2 );
dt << Select Labeled;
dt << Select Where(:age > 12,"extend");
```

Best

Uday

Uday

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 where using several conditions

The 'or' in JSL is the upper bar, or |. For example:

```
dt = Open( "$Sample_data/iris.jmp" );
dt << Select Where( :Sepal length > 6.7 & :Sepal length < 7.2);
dt << Select Where( :Sepal length == 6.7 | :Sepal length > 7.2);
```

I am not sure I follow your question about select labeled, can you give an example of which rows would actually be selected?

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

Re: Select where using several conditions

As can be seen in the Scripting Index:

Help==>Scripting Index

the Select Where() function allows for specification of "Current Selection("Extend"), which allows the results of a Select Where() to be added to the current selected rows.

Is this what you are looking for?

Jim

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

Re: Select where using several conditions

Hey, thank you ih,

The version of Select Where I wanted to find out is:

dt << Select Where( :Sepal length = 6.7 & :Sepal length = 6.8); /I for this I would need to add a "if any of these conditions apply"

With labelled I refer to the row state. I wanted to include in the "Select Where" several conditions including "labelled" (from row state).

Any ideas?

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

Re: Select where using several conditions

```
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Rows( [5, 7, 8, 10, 15] );
dt << Label( 1 );
dt << Clear Select;
Wait( 2 );
dt << Select Labeled;
```

Try this

Best

Uday

Uday

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

Re: Select where using several conditions

Thanks for the answer, now I only need to know how to combine it with the "Select Where" function.

Do you know the answer to this, too?

And can you explain me why I only address rows 5,7,8, 10 and 15 for select row?

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

@Pacco,

There are many ways to do this . One of the ways is to leverage the "extend" functionality. The second argument lets you either "extend" / "restrict" / "clear" current selection . So you can do something like this :

```
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Rows( [5, 7, 8, 10, 15] ); // For demo purpose only
dt << Label( 1 );
dt << Clear Select;
Wait( 2 );
dt << Select Labeled;
dt << Select Where(:age > 12,"extend");
```

Best

Uday

Uday

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

For your select statement:

`dt << Select Where( :Sepal length == 6.7 & :Sepal length == 6.8);`

You need to use the OR operator (|), not AND (&):

`dt << Select Where( :Sepal length == 6.7 | :Sepal length == 6.8);`

(edit - need to use == for equals comparison, not =)