Select where using several conditionsHello,
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.
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");
Re: Select where using several conditionsThanks 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?
Re: Select where using several conditionsFor 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
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
Re: Select where using several conditionsHey, 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?
Re: Select where using several conditionsAs 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?
Re: Select where using several conditionsThe '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?