月の初めから今日の日付までの日付間隔を定義します JMP16おはよう、
今朝以来、JMP 上のスクリプトで問題が発生しました。助けてください。
J'ai essayé de définir deux fonctions pour avoir la date de début de mois et la date d'aujourd'hui :
axe1:get_day_of_month- この関数は日付を入力として受け取り、日付を数値として返します。
axe1:get_dates- この関数は、今月の開始日と今日の日付を取得します。
次に、計算する関数:
//nb_total_ict および nb_total_fct: 実行されたテストの合計数をカウントできます
//nb_nok_ict および nb_nok_fct: すべてのテスト間の nok の数をカウントできるようにします
月初めから今日の日付までの ICT と FCT の NOK パーセンテージを計算するため。
私のコードの一部のコピーを添付します。
よろしくお願いします。
心から、
ヤス
// Fonction pour obtenir le jour du mois
axe1:get_day_of_month = Function({date},
day_of_month = Num(Format(date, "dd"));
day_of_month
);
// Fonction pour récupérer les dates
axe1:get_dates = Function({},
today_date = Format(Today(), "yyyy-mm-dd");
day_of_month = axe1:get_day_of_month(Today());
start_of_month = Format(Today() - (day_of_month - 1), "yyyy-mm-dd");
{start_of_month, today_date}
);
// Fonction pour calculer les pourcentages de NOK
axe1:calculate_nok_percentages = Function({dt},
{start_of_month, today_date} = axe1:get_dates();
// Initialisation des variables
nb_total_ict = 0;
nb_total_fct = 0;
nb_nok_ict = 0;
nb_nok_fct = 0;
// Récupération des lignes correspondant à la période spécifiée
FileRows = dt << Get Rows Where(
Num(Char(:Date)) >= Num(start_of_month) & Num(Char(:Date)) <= Num(today_date) & Contains(:File Name, "GOLDEN") == 0
);
total_rows = N Items(FileRows);
For(j = 1, j <= total_rows, j++,
If(dt:ICT_FCT[FileRows[j]] == "ICT",
nb_total_ict += dt:Nb_de_lignes[FileRows[j]];
If(dt:Result[FileRows[j]] == "NOK",
nb_nok_ict += dt:Nb_de_lignes[FileRows[j]]
)
);
If(dt:ICT_FCT[FileRows[j]] == "FCT",
nb_total_fct += dt:Nb_de_lignes[FileRows[j]];
If(dt:Result[FileRows[j]] == "NOK",
nb_nok_fct += dt:Nb_de_lignes[FileRows[j]]
)
);
);
// Calcul des pourcentages NOK
percent_nok_ict = (nb_nok_ict / nb_total_ict) * 100;
percent_nok_fct = (nb_nok_fct / nb_total_fct) * 100;
// Affichage des résultats
Window("Analyse des données") << Append(
V List Box(
Outline Box("Résultat NOK",
Border Box(
Text Box("Pourcentage de NOK ICT du " || start_of_month || " au " || today_date || " : " || Char(Round(percent_nok_ict, 2)) || "%"),
Text Box("Pourcentage de NOK FCT du " || start_of_month || " au " || today_date || " : " || Char(Round(percent_nok_fct, 2)) || "%")
)
)
)
);
);
自動化とスクリプトウィンドウズRe: 月の初めから今日の日付までの日付間隔を定義する JMP16どのような問題がありますか (コミュニティでの翻訳は間違っている可能性があります。問題を簡単に見つけられなかったためです)? おそらく、 Date Difference()またはDate Increment()を使用する必要があります。月の最初の日付を取得するには、intervalname として「month」、alignment として「start」を使用します。たとえば、今月の最初の日付などです。
Date Increment(Today(), "Month", 0, "start");
JMPには、日付の月を取得するためのMonth()や、この種の作業に役立つ多くの日付時刻関数もあります。

Re: 月の初めから今日の日付までの日付間隔を定義する JMP16日付テーブル (dt) に基づいて ICT と FCT のテーブルで NOK 結果のパーセンテージを計算するために、月の開始日と今日の日付を取得する 2 つの関数を定義しようとしました。
私は使った
axe1:get_day_of_month - This function takes a date as input and returns the day of the month as a number.axe1:get_dates - This function gets the start date of the current month and today's date.axe1:calculate_nok_percentages - This function calculates the percentage of NOK results for ICT and FCT based on a date table (dt). It filters the data for rows where the file name does not contain "GOLDEN" and then calculates the percentage of NOK for ICT and FCT for the specified date range.
しかし、毎回このエラーメッセージが表示されます:
JMPアラート
シンボル評価が再帰的すぎる(>250レベル)<< start_of_month のアクセスまたは評価中の 1 行目、月初め
1行目
スタックオーバーフローが検出されました。呼び出しレベルの最大数を超えました。実行は1行目で終了しました
Re: 月の初めから今日の日付までの日付間隔を定義する JMP16問題は For ループにあると思います。おそらく最適化できるので、ループを使用する必要さえないでしょう。行に関する知識がすでにある場合は、たとえばデータ テーブルの添え字を使用して、テーブルから必要な値を取得できます。また、計算を実行するために Subset + Summary を使用することもできます。
デモンストレーションに使用できるデータの小さな例 (またはモックアップ データ) を提供していただければ、さらに提案することができます。また、例を提供できる場合は、正しい結果に関する情報も提供してください。
Re: 月の初めから今日の日付までの日付間隔を定義する JMP162つの可能性がありますが、2番目が可能性が高いようです。
axe1:get_day_of_month = Function({date},
{ day_of_month },// 1: use local variables
day_of_month = Num(Format(date, "dd"));
day_of_month
);
// Fonction pour récupérer les dates
axe1:get_dates = Function({},
today_date = Format(Today(), "yyyy-mm-dd");
day_of_month = axe1:get_day_of_month(Today());
start_of_month = Format(Today() - (day_of_month - 1), "yyyy-mm-dd");
// 2: use evallist
evallist( {start_of_month, today_date} )
);
1: day_of_month はグローバルであり、関数間で混同される可能性があります
2: 返されるリストには値ではなく変数の名前が含まれ、それらはそれ自体に格納されます。これは再帰になると思います。
(見栄えの良いコードです!)
Re: 月の初めから今日の日付までの日付間隔を定義する JMP16ご提案とご協力に感謝いたします。
結局、今日の日付と月初めの日付を取得する get_dates 関数を修正し、元のループにエラーがいくつか見つかったため、別の For ループを使用しました。しかし、あなたの提案は非常に役に立ちました
それは get_dates 関数です:
axe1: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});
);改めて、ありがとうございました!