BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Highlighted
Pacco

Community Trekker

Joined:

Dec 15, 2017

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

Joined:

Jun 23, 2011

Solution

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

uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Solution

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
7 REPLIES 7
ih

Community Trekker

Joined:

Sep 30, 2016

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

Joined:

Jun 22, 2012

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

Community Trekker

Joined:

Dec 15, 2017

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

Community Trekker

Joined:

Sep 15, 2014

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

Community Trekker

Joined:

Dec 15, 2017

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

Community Trekker

Joined:

Sep 15, 2014

Solution

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

Joined:

Jun 23, 2011

Solution

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