Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoCiao a tutti,
Spero che stiate tutti bene! Ho una domanda e apprezzerei molto il vostro aiuto.
Ho lavorato su una funzione per creare un grafico di tracciamento NOK che mostra le percentuali NOK in un intervallo di date specifico. Ecco una rapida panoramica di cosa voglio che faccia la mia funzione:
- Ottengo le date di inizio e di fine del mese corrente.
- Successivamente creo una nuova tabella per memorizzare le percentuali NOK per ogni data, analizzando ogni giorno dall'inizio del mese fino a oggi.
- Quindi inserisce la data e le percentuali NOK corrispondenti nella nuova tabella.
- Infine, crea un grafico lineare che mostra le percentuali di NOK nell'intervallo di date.
La funzione funziona quasi completamente, ma ho riscontrato qualche problema.
TOP5:get_dates = Function({},
today_date = Format(Today(), "yyyy-mm-dd");
start_of_month = Format(Date Increment(Today(), "Month", 0, "Start"), "yyyy-mm-dd");
evallist({start_of_month, today_date});
);
TOP5:calculate_nok_percentages = Function({dt},
{start_of_month, today_date} = TOP5:get_dates();
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
nameFilesNok = Associative Array(Column(dt_top5, "Nom de fichier") << Get Values) << Get Keys;
total_nb_total_ict = 0;
total_nb_total_fct = 0;
total_nb_nok_ict = 0;
total_nb_nok_fct = 0;
For(k = 1, k <= N Items(nameFilesNok), k++,
FileRows = dt_top5 << get rows where(
:File Name == nameFilesNok[k] & Num(Char(:Date)) >= Num(start_of_month) & Num(Char(:Date)) <= Num(today_date) & Contains(:File Name, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
total_nb_total_ict += nb_total_ict;
total_nb_total_fct += nb_total_fct;
total_nb_nok_ict += nb_nok_ict;
total_nb_nok_fct += nb_nok_fct;
);
percent_nok_ict = (total_nb_nok_ict / total_nb_total_ict) * 100;
percent_nok_fct = (total_nb_nok_fct / total_nb_total_fct) * 100;
Eval List({percent_nok_ict, percent_nok_fct});
);
TOP5:create_nok_tracking_chart = Function({dt},
{start_of_month, today_date} = TOP5:get_dates();
dt_nok = New Table("NOK Percentages",
Add Rows(0),
New Column("Date", Character),
New Column("Percent NOK ICT", Numeric),
New Column("Percent NOK FCT", Numeric)
);
For(i = Num(start_of_month), i <= Num(today_date), i++,
// Correct date formatting
today_str = Format(Date(i), "yyyy-mm-dd");
Eval List({start_of_month, today_date}) = Eval List({today_str, today_str});
result = TOP5:calculate_nok_percentages(dt);
Insert Into(dt_nok,
today_str,
result[1],
result[2]
);
);
Graph Builder(
Size( 700, 500 ),
Show Control Panel( 0 ),
Variables( X( :Date ), Y( :Percent NOK ICT ), Y( :Percent NOK FCT ) ),
Elements(
Line(
X,
Y( 1 ),
Legend( 6 ),
Line Color( "Red" )
),
Line(
X,
Y( 2 ),
Legend( 8 ),
Line Color( "Blue" )
)
),
Legend Position( "Top" )
);
);
ho ricevuto questo messaggio di errore:
/*:
Unresolved name: Date JSL when accessing or evaluating "Date JSL". Date JSL( i ) /*###*/

Qualcuno potrebbe fornirmi qualche consiglio o suggerimento su come migliorare questa situazione?
Molte grazie!
Automazione e scriptingfinestreRe: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoIl problema è nella funzione create_nok_tracking_chart
Ho apportato alcune modifiche per semplificare il ciclo For, ma sfortunatamente non funziona:
current_date = Date(start_of_month);
While(current_date <= Date(today_date),
// Correct date formatting
today_str = Format(current_date, "yyyy-MM-dd");
result = TOP5:calculate_nok_percentages(dt);
Insert Into(dt_nok,
today_str,
result[1],
result[2]
);
// Increment date by 1 day
current_date = Date Increment(current_date, "Day", 1);
);
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoA cosa serve la funzione Date()?
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoHo usato Date() per creare un oggetto data da un elenco di date. Nel mio caso otterrò tutte le date dall'inizio del mese a oggi e la funzione Date() assicurerà che le date siano in un formato data che supporti l'aritmetica e i confronti delle date.
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoA mia conoscenza, non esiste una funzione Date() in JMP (esiste << Date() che può essere inviata alla casella del calendario, ma è una cosa completamente diversa).
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoOk, ho capito. In tal caso posso usare:
current_date = Format(start_of_month, "yyyy-MM-dd");
While ( current_date <= today_date,
today_str = Format(current_date, "yyyy-MM-dd");
result = TOP5:calculate_nok_percentages(dt);
Insert Into (dt_nok,
today_str
result[1],
result[2]
);
current_date = Date Increment(current_date, "Day", 1);
);Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoStai mescolando numeri (datenum) e stringhe. Io userei metodi molto più robusti per gestire le date rispetto alla tua funzione get_dates, dato che stai convertendo le date in stringhe. Dovresti mantenerle come date.
TOP5:get_dates = Function({},
today_date = Format(Today(), "yyyy-mm-dd");
start_of_month = Format(Date Increment(Today(), "Month", 0, "Start"), "yyyy-mm-dd");
evallist({start_of_month, today_date});
);
(Vi ho già fornito più volte questi metodi più robusti nei miei esempi).
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoSì, è quello che sto cercando di fare ora. Manterrò il formato data e lavorerò sulla logica per vedere se funziona.
Grazie e scusatemi se le mie domande sono ripetitive e a volte possono sembrare sciocche. È solo perché ho iniziato a usare JMP e il linguaggio JSL due mesi fa per il mio tirocinio.
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoSono davvero confuso. Ho provato questo metodo:
" ),
Format( "Date Abbrev", 20 )
) << Set Field Width(10);
date = today_date;
While(Num(Char(date)) >= Num(start_of_month),
{percent_nok_ict, percent_nok_fct} = TOP5:calculate_nok_percentages_for_date(dt, date);
dt_results << Add Rows(
{Format(date, "yyyy-mm-dd"), percent_nok_ict, percent_nok_fct}
);
date = Date Increment(date, "day", -1);
);
dt_results;
);
TOP5:calculate_nok_percentages_for_date = Function({dt, specific_date},
{start_of_month, today_date} = TOP5:get_dates();
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
nameFilesNok = Associative Array(Column(dt_top5, "Nom de fichier") << Get Values) << Get Keys;
total_nb_total_ict = 0;
total_nb_total_fct = 0;
total_nb_nok_ict = 0;
total_nb_nok_fct = 0;
For(k = 1, k <= N Items(nameFilesNok), k++,
FileRows = dt_top5 << get rows where(
:File Name == nameFilesNok[k] & Num(Char(:Date)) >= Num(start_of_month) & Num(Char(:Date)) <= Num(specific_date) & Contains(:File Name, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
total_nb_total_ict += nb_total_ict;
total_nb_total_fct += nb_total_fct;
total_nb_nok_ict += nb_nok_ict;
total_nb_nok_fct += nb_nok_fct;
);
percent_nok_ict = (total_nb_nok_ict / total_nb_total_ict) * 100;
percent_nok_fct = (total_nb_nok_fct / total_nb_total_fct) * 100;
Eval List({percent_nok_ict, percent_nok_fct});
);
e quando posso la mia funzione è:TOP5:Do = Function ({nb_date1, nb_date2},
//Ouverture de la table de données
dt = Open( "/D:/Project JMP/Tables/TableData PY.jmp", invisible );
// Calculate NOK percentages
{percent_nok_ict, percent_nok_fct} = TOP5:calculate_nok_percentages(dt);
// Call the new function to get NOK percentages over time
dt_results = TOP5:calculate_nok_percentages_over_time(dt);
// Display the results table
dt_results << Show Window;Names Default To Here( 1 );
TOP5 = New Namespace(
"TOP5"
);
TOP5:get_dates = Function({},
today_date = Format(Today(), "yyyy-mm-dd");
start_of_month = Format(Date Increment(Today(), "Month", 0, "Start"), "yyyy-mm-dd");
evallist({start_of_month, today_date});
);
TOP5:calculate_nok_percentages = Function({dt},
{start_of_month, today_date} = TOP5:get_dates();
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
nameFilesNok = Associative Array(Column(dt_top5, "Nom de fichier") << Get Values) << Get Keys;
total_nb_total_ict = 0;
total_nb_total_fct = 0;
total_nb_nok_ict = 0;
total_nb_nok_fct = 0;
For(k = 1, k <= N Items(nameFilesNok), k++,
FileRows = dt_top5 << get rows where(
:File Name == nameFilesNok[k] & Num(Char(:Date)) >= Num(start_of_month) & Num(Char(:Date)) <= Num(today_date) & Contains(:File Name, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
total_nb_total_ict += nb_total_ict;
total_nb_total_fct += nb_total_fct;
total_nb_nok_ict += nb_nok_ict;
total_nb_nok_fct += nb_nok_fct;
);
percent_nok_ict = (total_nb_nok_ict / total_nb_total_ict) * 100;
percent_nok_fct = (total_nb_nok_fct / total_nb_total_fct) * 100;
Eval List({percent_nok_ict, percent_nok_fct});
);
TOP5:calculate_nok_percentages_over_time = Function({dt},
{start_of_month, today_date} = TOP5:get_dates();
dt_results = New Table("NOK Percentages Over Time",
New Column("Date", Numeric),
New Column("Percent_NOK_ICT", Numeric),
New Column("Percent_NOK_FCT", Numeric)
);
// Set the format for the Date column
Column(dt_results, "Date") << Data Type(
Numeric,
Format( "Format Pattern", "<YYYY>-<MM>-<DL><DD>", 10 ),
Input Format( "Format Pattern", "<YYYY>-<MM>-</MM></YYYY></DD></DL></MM></YYYY>
Continuo a ricevere un errore ogni volta.
Ciò che voglio fare è creare una funzione che calcoli le percentuali NOK come la seconda funzione TOP5:calculate_nok_percentages_over_time . La differenza è che questa funzione calcolerà la percentuale NOK tra la data odierna e l'inizio del mese, poi da ieri all'inizio del mese e così via, fino a raggiungere l'inizio del mese. I risultati dovrebbero essere archiviati in una nuova tabella in modo da poterli usare per creare grafici.
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoChe errore stai riscontrando?
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definito/*:
L'argomento deve essere numerico alla riga 1 quando si accede o si valuta 'Format', Format/*###*/(date, "yyyy-mm-dd").
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoProbabilmente stai ricevendo quell'errore perché la tua variabile data è una stringa e Format() richiede che tu abbia una variabile numerica. Immagino che l'errore derivi da questo

date è uguale a today_date, today_date deriva da TOP5:get_dates() che restituisce stringhe. Mantieni le date come valori numerici ed eviterai tutti questi problemi (non c'è bisogno di usare conversioni Num(Char()), specialmente quando parti da Today() che è un valore numerico).
Ti consiglio di leggere le parti relative a data e ora dalla Guida allo scripting, partendo da questo https://www.jmp.com/support/help/en/18.0/#page/jmp/datetime-functions-and-formats.shtml#
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoHo preso in considerazione i tuoi suggerimenti e ho provato questo metodo. Tuttavia, ho ancora un problema: la mia funzione restituisce una tabella con punti nelle righe.

e ho mantenutodate = today_date;perché quando eseguo lo script contoday_datecome parametro direttamente,JMP non risponde.Non capisco perché assegnaredate = today_dategestisce la corsa in modo più efficiente.
"),
Format("Date Abbrev", 20)
) << Set Field Width(10);
date = today_date;
While(date >= start_of_month,
{percent_nok_ict, percent_nok_fct} = TOP5:calculate_nok_percentages_for_date(dt, date);
dt_results << Add Rows(
{Format(date, "yyyy-mm-dd"), percent_nok_ict, percent_nok_fct}
);
date = Date Increment(date, "day", -1);
);
dt_results;
);
TOP5:calculate_nok_percentages_for_date = Function({dt, specific_date},
{start_of_month, today_date} = TOP5:get_dates_percent();
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
nameFilesNok = Associative Array(Column(dt_top5, "Nom de fichier") << Get Values) << Get Keys;
total_nb_total_ict = 0;
total_nb_total_fct = 0;
total_nb_nok_ict = 0;
total_nb_nok_fct = 0;
For(k = 1, k <= N Items(nameFilesNok), k++,
FileRows = dt_top5 << get rows where(
:File Name == nameFilesNok[k] & :Date >= start_of_month & :Date <= specific_date & Contains(:File Name, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
total_nb_total_ict += nb_total_ict;
total_nb_total_fct += nb_total_fct;
total_nb_nok_ict += nb_nok_ict;
total_nb_nok_fct += nb_nok_fct;
);
percent_nok_ict = (total_nb_nok_ict / total_nb_total_ict) * 100;
percent_nok_fct = (total_nb_nok_fct / total_nb_total_fct) * 100;
Eval List({percent_nok_ict, percent_nok_fct});
);
grazie in anticipo. TOP5:get_dates_percent = Function({},
today_date = Today();
start_of_month = Date Increment(Today(), "Month", 0, "Start");
evallist({start_of_month, today_date});
);
TOP5:calculate_nok_percentages_over_time = Function({dt},
{start_of_month, today_date} = TOP5:get_dates_percent();
dt_results = New Table("NOK Percentages Over Time",
New Column("Date", Numeric),
New Column("Percent_NOK_ICT", Numeric),
New Column("Percent_NOK_FCT", Numeric)
);
// Set the format for the Date column
Column(dt_results, "Date") << Data Type(
Numeric,
Format("Format Pattern", "<YYYY>-<MM>-<DL><DD>", 10),
Input Format("Format Pattern", "<YYYY>-<MM>-</MM></YYYY></DD></DL></MM></YYYY>
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoI punti nelle celle indicano dati mancanti poiché sono presenti colonne di tipo dati numerici.
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoNon sono sicuro che il problema riguardi la compatibilità del codice con il mio set di dati.
Ho allegato un esempio della mia tabella dati per vostro riferimento.
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoLe tue date sono valori numerici se intendi questo
Names Default To Here(1);
dt = Open("$DOWNLOADS/TableData SVI PY.jmp");
vals = Column(dt, "Date") << get values;
show(vals);


Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitosì le mie date sono valori numerici
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoAggiornamenti:)
Ho provato a usare la funzione in questo modo, ho inserito tutte le date nel formato numerico, ma come sempre ho ricevuto questo errore, credo sia nella colonna Data:
/*:
"Cannot set the value of column 'Percent_NOK_ICT' because the row number (0) is not valid."
// Ouvrir le fichier de données
dt = Open("$DOWNLOADS/TableData SVI PY.jmp", invisible);
// Créer un résumé des données
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
// Créer la table de résultats
dt_results = New Table("NOK Percentages Over Time",
New Column("Date", Numeric),
New Column("Percent_NOK_ICT", Numeric),
New Column("Percent_NOK_FCT", Numeric)
);
// Obtenir les noms de fichiers NOK
nameFilesNok = Associative Array(Column(dt_top5, "Nom de fichier") << Get Values) << Get Keys;
// Boucle sur chaque jour depuis aujourd'hui jusqu'au début du mois
For(i = Today(), i >= Num(Date Increment(Today(), "Month", 0, "Start")), i -= 1,
current_date = i;
total_nb_total_ict = 0;
total_nb_total_fct = 0;
total_nb_nok_ict = 0;
total_nb_nok_fct = 0;
// Calcul des pourcentages NOK pour chaque jour
For(k = 1, k <= N Items(nameFilesNok), k++,
FileRows = dt_top5 << get rows where(
:Nom de fichier == nameFilesNok[k] & Num(Date(:Date)) >= current_date & Num(Date(:Date)) <= Num(Today()) & Contains(:Nom de fichier, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
total_nb_total_ict += nb_total_ict;
total_nb_total_fct += nb_total_fct;
total_nb_nok_ict += nb_nok_ict;
total_nb_nok_fct += nb_nok_fct;
);
// Assurez-vous que les totaux ne sont pas zéro avant de calculer les pourcentages
If(total_nb_total_ict > 0,
percent_nok_ict = (total_nb_nok_ict / total_nb_total_ict) * 100;
,
percent_nok_ict = 0;
);
If(total_nb_total_fct > 0,
percent_nok_fct = (total_nb_nok_fct / total_nb_total_fct) * 100;
,
percent_nok_fct = 0;
);
// Ajouter une nouvelle ligne et définir les valeurs
dt_results << Add Rows(1);
last_row_index = N Rows(dt_results);
dt_results:Date[last_row_index] = current_date;
dt_results:Percent_NOK_ICT[last_row_index] = percent_nok_ict;
dt_results:Percent_NOK_FCT[last_row_index] = percent_nok_fct;
);
// Affichage des résultats
dt_results;
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definito
Potrebbe essere la funzione Date() a causare problemi (non ne sono sicuro perché non so come l'hai definita).
Re: Tracciare un grafico di monitoraggio della distribuzione su un intervallo di date definitoIn allegato troverete una versione aggiornata del codice, utile per chiunque sia interessato a questo argomento!
// Ouvrir le fichier de données
dt = Open( "/D:/Project JMP/Tables/TableDataPY.jmp", invisible );
today_date = Format(Today(), "yyyy-mm-dd");
start_of_month = Format(Date Increment(Today(), "Month", 0, "Start"), "yyyy-mm-dd");
evallist({start_of_month, today_date});
dt_top5 = dt << Summary(
Group(:Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :Reason Error, :CodeError),
Freq("Aucun(e)"),
Weight("Aucun(e)"),
invisible
);
results_table = New Table( "Results",
New Column( "Date", Character ),
New Column( "Percent NOK ICT", Numeric ),
New Column( "Percent NOK FCT", Numeric ),
New Column( "Total ICT", Numeric ),
New Column( "NOK ICT", Numeric ),
New Column( "Total FCT", Numeric ),
New Column( "NOK FCT", Numeric )
);
For(day = Num(start_of_month), day <= Num(today_date), day = Date Increment(day, "Day", 1),
current_date = Format(day, "yyyy-mm-dd");
FileRows = dt_top5 << get rows where(
Num(Char(:Date)) == Num(current_date) & Contains(:Nom de fichier, "GOLDEN") == 0
);
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt_top5:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict = nb_total_ict + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_ict = nb_nok_ict + dt_top5:Nb. de lignes[FileRows[j]]
);
, dt_top5:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct = nb_total_fct + dt_top5:Nb. de lignes[FileRows[j]];
If(dt_top5:Result[FileRows[j]] == "NOK",
nb_nok_fct = nb_nok_fct + dt_top5:Nb. de lignes[FileRows[j]]
);
)
);
If(nb_total_ict > 0,
percent_nok_ict = (nb_nok_ict / nb_total_ict) * 100,
percent_nok_ict = 0
);
If(nb_total_fct > 0,
percent_nok_fct = (nb_nok_fct / nb_total_fct) * 100,
percent_nok_fct = 0
);
results_table << Add Rows(1);
row_index = N Rows(results_table);
results_table:Date[row_index] = current_date;
results_table:Percent NOK ICT[row_index] = percent_nok_ict;
results_table:Percent NOK FCT[row_index] = percent_nok_fct;
results_table:Total ICT[row_index] = nb_total_ict;
results_table:NOK ICT[row_index] = nb_nok_ict;
results_table:Total FCT[row_index] = nb_total_fct;
results_table:NOK FCT[row_index] = nb_nok_fct;
);
results_table << Save( "D:/Project JMP/Tables Resultats NOK percentages/Results.jmp" );
// Fermer toutes les tables ouvertes
Close( dt, "No Save" );
Close( dt_top5, "No Save" );
<BR />