cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Yngeinstn
Level IV

Changing column values based on the column spec limit

We have a phase test that sometimes likes to flop the value by 360 degrees. I would like a script that can look through the table column data, take an average and then compare it to the LSL / USL. If the sign of the average is opposite the spec limit add 360 to that value.

 

I can't do a blanket If( :test < 0, t1 = :column + 360; t1; ) due to the way the tester handles the data.

 

I have attached a sample table and the last two columns are where my issue is.

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Changing column values based on the column spec limit

See if this little script gives you what you want

Names Default To Here( 1 );
dt = Current Data Table();

colList = dt << get column names( continuous, string );

For( i = 1, i <= N Items( colList ), i++,
	specs = Column( dt, colList[i] ) << get property( "spec limits" );
	If( Is Missing( specs["LSL"] ) == 0 & Is Missing( specs["USL"] ) == 0,
		If( !(specs["LSL"] <= Col Mean( Column( dt, colList[i] ) ) <= specs["USL"]),
			For Each Row( As Column( dt, colList[i] ) = -1 * As Column( dt, colList[i] ) )
		)
	);
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Changing column values based on the column spec limit

See if this little script gives you what you want

Names Default To Here( 1 );
dt = Current Data Table();

colList = dt << get column names( continuous, string );

For( i = 1, i <= N Items( colList ), i++,
	specs = Column( dt, colList[i] ) << get property( "spec limits" );
	If( Is Missing( specs["LSL"] ) == 0 & Is Missing( specs["USL"] ) == 0,
		If( !(specs["LSL"] <= Col Mean( Column( dt, colList[i] ) ) <= specs["USL"]),
			For Each Row( As Column( dt, colList[i] ) = -1 * As Column( dt, colList[i] ) )
		)
	);
);
Jim
Yngeinstn
Level IV

Re: Changing column values based on the column spec limit

Thank you Mr. Nelson.

 

I had to modify the script a little bit. I changed the multiplication to addition and changed the Mean to Median. I didn't account for catastrophic failures when i made the original post. Columns 40 and 41 had col mean values that were not between the LSL and USL.

 

Names Default To Here( 1 );
dt = Current Data Table();

colList = dt << get column names( continuous, string );

For( i = 1, i <= N Items( colList ), i++,
	specs = Column( dt, colList[i] ) << get property( "spec limits" );
	If( Is Missing( specs["LSL"] ) == 0 & Is Missing( specs["USL"] ) == 0,
		If( !(specs["LSL"] <= Col Median( Column( dt, colList[i] ) ) <= specs["USL"]),
			For Each Row( As Column( dt, colList[i] ) = 360 + As Column( dt, colList[i] ) )
		)
	);
);