Cómo obtener una columna pass_failMe gustaría obtener una columna pass_fail, y @txnelson llegó al guión.
Pero t su script no funciona si alguna de las muchas columnas no tiene una especificación en el medio.
¿Cómo puedo arreglarlo?
Names Default To Here( 1 );
dtOrig = current data table();
colNamesList = dtOrig << get column names( continuous, string );
// Create a work table of just the continuous columns
dt = dtOrig << subset( columns( colNamesList ), selected rows( 0 ) );
// Loop across all of the columns and apply a Range Check to eliminate
// all data outside of the upper and lower spec limits
For( theCol = 1, theCol <= N Items( colNamesList ), theCol++,
specs = Column( dt, colNamesList[theCol] ) << get property( "spec limits" );
Eval(
Substitute(
Expr(
Column( dt, colNamesList[theCol] ) << set property(
"Range Check",
(LELE( __LSL__, __USL__ ))
)
),
Expr( __LSL__ ), specs["LSL"],
Expr( __USL__ ), specs["USL"]
)
);
// Now convert the column to numeric
Column( dt, colNamesList[theCol] ) << data type( character );
// Now find all cells where values were eliminated
dt << select where( As Column( dt, colNamesList[theCol] ) == "" );
// If non passing rows were found, process the column to change the passing rows to
// a blank, and non passing to the name of the column
If( N Rows( dt << get selected rows ) > 0,
// Now set all eliminated cells to have the value of the name of the column
Column( dt, colNamesList[theCol] )[dt << get selected rows] = Column( dt, colNamesList[theCol] ) <<
get name;
// Invert the row selection, to select all rows where values passed and set them to a blank
dt << invert row selection;
Column( dt, colNamesList[theCol] )[dt << get selected rows] = "";
, // else set all
Column( dt, colNamesList[theCol] )[Index( 1, N Rows( dt ) )] = ""
);
);
// Now create a new column to hold the information on either that the row Passed or
// which columns failed
dt << New Column( "Pass_Fail", Character );
// Loop across all rows and set the values for the new column
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
If( Trim( Concat Items( dt[theRow, 0, ""] ) ) == "",
:Pass_Fail[theRow] = "Pass"
,
thePass_Fail = Concat Items( dt[theRow, 0], "," );
For( i = Length( thePass_Fail ), i >= 2, i--,
If( Substr( thePass_Fail, i, 1 ) == ",",
If( Substr( thePass_Fail, i - 1, 1 ) == ",",
thePass_Fail = Substr( thePass_Fail, 1, i - 1 ) || Substr( thePass_Fail, i + 1 )
)
)
);
If( Right( thePass_Fail, 1) == ",", thePass_Fail = Left( thePass_Fail, length( thePass_Fail ) - 1 ) );
:Pass_Fail[theRow] = thePass_Fail;
)
);
// Only the new column is what is needed, so delete all other columns
dt << delete columns( eval(colNamesList) );
// Add the new column to the original data table
dtOrig << Update(
With( dt )
);
// Delete the no longer needed work table
close(dt, nosave );
Re: Cómo obtener una columna pass_failTXnelson escribe un código realmente fabuloso!
Sin embargo, quizás esté buscando una solución simple como:
If( :Data >= 42,"Too High",If( :Data < 7,"Too Low","Just Right"))

esto es solo una declaración anidada If si los valores de los datos son 42 o más, la fórmula devuelve "Too High", si los datos son menores que 7, devuelve "Too Low", y si no es ni demasiado alto ni demasiado bajo, entonces el la fórmula devuelve "Just Right"
Puede pegar la fórmula en el editor de fórmulas y luego sustituirla por el nombre, los valores y los mensajes correctos de la columna. (Haga clic derecho en el nombre de la columna, haga clic en la fórmula y pegue el JSL anterior en el cuadro de diálogo)
Salud,
si
Re: Cómo obtener una columna pass_failMe gusta simple, como yo!
Entonces lo simplifiqué (no se requiere anidar):
If( :Data >= 42, "Too High", :Data < 7, "Too Low", "Just Right")
Re: Cómo obtener una columna pass_failNecesito agradecer @Byron_JMP por responder Tenía la intención de responder a esta discusión, y antes de hacerlo, pasó a una página más antigua y, por lo tanto, se me cayó de la memoria. La respuesta de Byron devolvió la discusión a mi NameSpace.
Creo que todo lo que tiene que hacer para solucionar su problema es validar que una columna dada tiene límites de especificaciones asociados. Y, si no se encuentran límites de especificación, no procese esa columna. A continuación se muestra un cambio sugerido algo críptico que puede hacer lo que desea. Lo básico del problema es usar una función If () para procesar solo el código cuando se encuentran los límites de especificaciones. Este es un reemplazo para sus especificaciones actuales = línea de código
clear symbols(specs);
specs = Column( dt, colNamesList[theCol] ) << get property( "spec limits" );
If(isEmpty(specs)==0,
<ALL of="" the="" code="" to="" the="" end="" of="" the="" for="" loop=""></ALL>
Re: Cómo obtener una columna pass_fail¡Gracias por tu ayuda!
¡Este código funciona muy bien!
Gracias:)