cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

select where conditions not met

I have a script running everyday to determine what parts have failed.  We had a day where none of the parts failed and since my select where condition was not ("Fail") it grabbed all the passing parts and output them to the next table.  How do I write it so that if no parts fail, the next tables should be blank? 

Example:

Data Table ("Parts")<< select where (:PassOrFail == "Fail");
Data Table ("Parts")<< subset (Output Table ("Fails", selected rows (1),selected columns(0)));

 

Since there were no "Fail" in my PassOrFail Column, the output table "Fails" was just a replica of the original table "Parts"

 

2 REPLIES 2
txnelson
Super User

Re: select where conditions not met

Data Table ("Parts")<< select where (:PassOrFail == "Fail");
If( N Rows( Data Table("Parts") << get selected rows ) > 0,
     Data Table ("Parts")<< subset (Output Table ("Fails", selected rows (1),selected columns(0)));
);
Jim
pmroz
Super User

Re: select where conditions not met

Use get rows where instead of select where:

fail_rows = Data Table( "Parts" ) << get rows where( :PassOrFail == "Fail" );

if (nrows(fail_rows) > 0,
	Data Table( "Parts" ) << subset(rows(fail_rows), selected columns( 0 ),
		Output Table( "Fails")
	);
);

Recommended Articles