cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
jcminor
Level II

Using an OR statement in selecting rows for exclusion

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

Re: Using an OR statement in selecting rows for exclusion

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

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: Using an OR statement in selecting rows for exclusion

My test case works great, using your code.

select.PNG

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
jcminor
Level II

Re: Using an OR statement in selecting rows for exclusion

@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.

txnelson
Super User

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

Re: Using an OR statement in selecting rows for exclusion

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
jcminor
Level II

Re: Using an OR statement in selecting rows for exclusion

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

jcminor
Level II

Re: Using an OR statement in selecting rows for exclusion

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