pass_fail 列を取得したいのですが、 @txnelson脚本にできました。
でも、このスクリプトは、多くの列のいずれかに真ん中に仕様がない場合には機能しません。
どうすれば修正できますか?
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 );
感謝しなければなりません@バイロン_JMP応答するため。私はこの議論に応答するつもりだったのですが、応答する前に古いページに移動してしまい、記憶から抜け落ちてしまいました。Byron の返答により、議論は再び私の NameSpace に戻りました。
問題を解決するために必要なのは、特定の列に関連付けられた仕様制限があることを検証することだけだと思います。また、仕様制限が見つからない場合は、その列を処理しないでください。以下は、あなたが望むことを実現する可能性のある、やや不可解な提案された変更です。問題の基本は、仕様制限が見つかった場合にのみコードを処理するために If() 関数を使用することです。これは現在の仕様 = コード行の置き換えです。
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>
私らしくシンプルが好き!
そこで、それを単純化しました(ネストは必要ありません)。
If( :Data >= 42, "Too High", :Data < 7, "Too Low", "Just Right")
TXnelson は本当に素晴らしいコードを書きます。
ただし、次のような単純なソリューションを探しているかもしれません。
If( :Data >= 42,"Too High",If( :Data < 7,"Too Low","Just Right"))

これは単なるネストされた If ステートメントです。データ値が 42 以上の場合、式は「高すぎる」を返し、データが 7 未満の場合は「低すぎる」を返し、高すぎも低すぎもしない場合、式は「ちょうどよい」を返します。
数式を数式エディターに貼り付けて、正しい列名、値、メッセージに置き換えることができます。 (列名を右クリックし、 式 をクリックして、上記の JSL をダイアログに貼り付けます)
乾杯、
B