cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
Pacco
Level III

Select where using several conditions

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
pmroz
Super User

Re: Select where using several conditions

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 =) 

View solution in original post

uday_guntupalli
Level VIII

Re: Select where using several conditions

@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

View solution in original post

7 REPLIES 7
ih
Super User (Alumni) ih
Super User (Alumni)

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?

 

txnelson
Super User

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
Pacco
Level III

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?

 

uday_guntupalli
Level VIII

Re: Select where using several conditions

@Pacco,

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
Pacco
Level III

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?

uday_guntupalli
Level VIII

Re: Select where using several conditions

@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
pmroz
Super User

Re: Select where using several conditions

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 =)