Here is a rework of your script that I think simplifies it, and still provides you with your yields
Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );
dt1 = dt << subset( all rows, all columns );
//spec table
dtbz = Data Table( "Spec" );
LSL = dtbz[0, 4];
USL = dtbz[0, 5];
//dtbz << New Column( "combine", formula( :Project || :Item ) );
dtbz << New Column( "combine", character, formula( :Project || :Item ) );
// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item << get values(), <<levels )[2];
// items = dt << get column names( string, numeric );
Summarize( dtbz, items = by( :item ) );
// new column to justify the pass/no pass
For( i = 1, i <= N Items( items ), i++,
it = items[i];
/* dt1 << New Column( it || "—yield",
formula(
If(
:Project == "A" & N Items( Loc( dtbz:combine << get as matrix(), "A" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "A" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "A" || it )[1]],
:Project == "B" & N Items( Loc( dtbz:combine << get as matrix(), "B" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "B" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "B" || it )[1]],
:Project == "C" & N Items( Loc( dtbz:combine << get as matrix(), "C" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "C" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "C" || it )[1]],
:Project == "D" & N Items( Loc( dtbz:combine << get as matrix(), "D" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]],
)
)
);*/
Eval(
Substitute(
Expr(
dt1 << New Column( it || "—yield",
formula(
curProject = :Project;
Try( dtbzRow = (dtbz << get rows where( dtbz:Project == curProject & dtbz:item == __it__ ))[1], 0 );
If( dtbzRow > 0,
If( dtbz:LSL[dtbzRow] <= As Column( dt1, __it__ ) <= dtbz:USL[dtbzRow],
1,
0
)
);
)
)
),
Expr( __it__ ), it
)
);
);
Jim