Come funziona la formula pass/fail?Ho un problema: le formule restituiscono valori nulli.
La tabella raw contiene i dati grezzi ed è presente una tabella di specifiche, che viene utilizzata per determinare se i dati grezzi superano o meno la verifica in base alla tabella di specifiche. Ho scritto un file JSL, per favore aiutatemi a capire qual è il problema, grazie.
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, 3];
USL = dtbz[0, 4];
dtbz << New Column( "combine", formula( :Project || :Item ) );
// Create separate judgment columns for the columns to be judged
items = Design( dtbz:Item << get values(), <
<LEVELS>
0, dtbz:LSL[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:LSL[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:LSL[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:LSL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]] <= Column( dt1, items[i] ) <= dtbz:USL[ Loc( dtbz:combine << get as matrix(), "D" || it )[1]], ) ) ) );
</LEVELS>
Automazione e scriptingRe: Come funziona la formula pass/fail?Ecco una rielaborazione del tuo copione che penso lo semplifichi e ti fornisca comunque i tuoi rendimenti

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> 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
)
);
);</LEVELS>
Re: Come funziona la formula pass/fail?Grazie mille per la tua rapida risposta, funziona.
Re: Come funziona la formula pass/fail?CIAO Jim , un altro piccolo problema è che quando i corrispondenti USL e LSL non vengono trovati nella tabella delle specifiche, dovrebbe essere restituito il valore null, ma questo codice viene eseguito e restituisce 0. Non so cosa stia succedendo.
Re: Come funziona la formula pass/fail?La modifica originale che ho fornito presupponeva che tutti i limiti delle specifiche fossero disponibili.Per tenere conto della possibilità di limiti mancanti, le formule devono essere modificate per gestire tali casi.Il JSL di seguito si adatta a un paio di possibili casi, ma potrebbe essere necessario aggiungerne altri, come:
L'USL è inferiore all'LSL
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" );
// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item << get values(), <<LEVELS> 0 & Is Missing( dtbz:LSL[dtbzRow] ) == 0 & Is Missing( dtbz:USL[dtbzRow] ) == 0,
If( dtbz:LSL[dtbzRow] <= As Column( dt1, __it__ ) <= dtbz:USL[dtbzRow],
1,
0
),
.
);
)
)
),
Expr( __it__ ), it
)
);
);</LEVELS>Re: Come funziona la formula pass/fail?Grazie, ma ho una domanda, perché il codice precedente presentava questo problema? Vedo che la logica del codice precedente è: se trovato nella tabella SPEC, allora il giudizio, non trovato e non c'è codice, dovrebbe essere il valore vuoto ah, perché lo sta ancora giudicando?
Re: Come funziona la formula pass/fail?I valori calcolati persistono da riga a riga, quindi se una condizione nella riga 2 non modifica il valore calcolato, il valore calcolato per la riga 1 rimane invariato.
Re: Come funziona la formula pass/fail?Grazie! L'ho provato e in effetti sotto l'esecuzione del codice precedente, se non si trova nella tabella SPEC, passerà dal dtbzRow della riga precedente. Chiaramente non è stato trovato, ma preme comunque il valore della riga precedente. Non lo trovo nelle formule di routine, succede solo quando uso una ricerca di un'altra tabella?
Re: Come funziona la formula pass/fail?Le variabili di memoria in JMP rimangono persistenti finché non vengono modificate.Ecco uno script che crea una nuova colonna e formula che imposta una variabile "a" sulla riga 1, quindi la modifica alla riga 10. Puoi vedere che il valore di "a" non cambia fino alla riga 10, ma rimane al valore impostato iniziale fino ad allora.
Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// New column: Column 6
Data Table( "Big Class" ) << New Column( "test",
Numeric,
"Continuous",
Format( "Best", 12 )
);
dt:test << set formula(
If( Row() == 1, a = 1 );
If( Row() == 10, a = a + 1 );
:test = a;
);
Re: Come funziona la formula pass/fail?Capisco, è perché se non può essere trovato nell'istruzione try, non verrà assegnato ad esso, risultando nel valore originale, ma non può essere trovato nella prima riga all'inizio, quindi com'è ha assegnato?
Re: Come funziona la formula pass/fail?Ho annotato la sceneggiatura nel tentativo di facilitarne la lettura.Ho anche apportato una piccola modifica alla funzione Try(), spostandola per fornire un risultato a dtbzRow.
Vedi se questo aiuta nella comprensione
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" );
// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item << get values(), <<LEVELS> 0 & Is Missing( dtbz:LSL[dtbzRow] ) == 0 &
Is Missing( dtbz:USL[dtbzRow] ) == 0,
// If the column's value is between the LSL and USL
// the value is set to 1, if outside one of the
// limits it is set to 0
If(
dtbz:LSL[dtbzRow] <= As Column( dt1, __it__ ) <= dtbz
:USL[dtbzRow],
1,
0
),
.
);
)
)
),
Expr( __it__ ), it
)
);
);</LEVELS>Re: Come funziona la formula pass/fail?Capisco, grazie per la pazienza!