cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
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")
	);
);