これらの値がどのように計算されるのかわかりません。 4月までは3か月あるので4月しか使えませんが、テスト数は8、一意のシリアル番号の数は6にすべきではないでしょうか。
月ごとに 1 行しか存在しないため、最初に概要テーブルを作成し、そこで計算を実行するのが最も簡単であると考えられます。
申し訳ありませんが、1 月と 2 月の結果を表示するのは混乱を招く可能性があります。そして、「3か月前」の説明がうまくできませんでした。つまり、4 月の概要行では、2 月、3 月、4 月に実行されたすべてのテストを数え、同じ期間の一意のシリアル番号をすべて数えます。3 月の概要行も同様ですが、1 月、2 月、3 月を使用します。1 月と 2 月のサマリーは空白にするか、1 月のデータのみに基づく 1 月と 1 月と 2 月のデータのみに基づく 2 月のサマリーを受け入れます。
重要な点は、一部のシリアル番号は異なる月に複数回テストされるため、期間を 1 か月に限定すると、テスト数とテストされる一意のユニット数が正確ではなくなるということです。
これは間違いなくこれを行う唯一の方法ではありませんが、可能なオプションの 1 つです
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(10),
Compress File When Saved(1),
New Column("Month",
Character,
"Nominal",
Set Values({"Jan", "Jan", "Jan", "Feb", "Feb", "Feb", "Mar", "Mar", "Apr", "Apr"})
),
New Column("Serial # of unit tested",
Numeric,
"Nominal",
Format("Best", 12),
Set Values([1001, 1001, 1002, 1002, 1003, 1004, 1005, 1006, 1006, 1006])
)
);
dt_results = New Table("Untitled 3",
Compress File When Saved(1),
New Column("Month", Character, "Nominal", Set Values({})),
New Column("# of tests, prior 3 months", Numeric, "Continuous", Format("Best", 12), Set Values([])),
New Column("# of unique SN tested, prior 3 months", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);
//
order = {"Jan", "Feb", "Mar", "Apr"};
Summarize(dt, uniq_months = By(:Month));
For Each({cur_month}, uniq_months,
cur_month_idx = Contains(order, cur_month);
months_of_interest = If(cur_month_idx < 3,
order[1::cur_month_idx];
,
order[(cur_month_idx - 2)::cur_month_idx];
);
// number of tests is same as number of rows
rows_of_interest = dt << Get Rows Where(Contains(months_of_interest, :Month));
nr_of_tests = N Items(rows_of_interest);
// number of unique items we can get with associative array
unique_snrs = Associative Array(dt[rows_of_interest, "Serial # of unit tested"]) << get keys;
nr_of_unique = N Items(unique_snrs);
cur_month_result = Eval List({cur_month, nr_of_tests, nr_of_unique});
dt_results << Add Row(1);
dt_results[N Row(dt_results), 0] = cur_month_result;
);

複数年ある場合は修正が必要になります
3 か月間の表を要約する方法を見つけようとしています。「ラグ」関数と「列ローリング」関数を使用してさまざまなアプローチを試しましたが、まだ成功していません。何かアドバイス?JMP16を使用しています
元データの例
月 | テストされたユニットのシリアル番号 |
1月 | 1001 |
1月 | 1001 |
1月 | 1002 |
2月 | 1002 |
2月 | 1003 |
2月 | 1004 |
3月 | 1005 |
3月 | 1006 |
4月 | 1006 |
4月 | 1006 |
ご希望の集計データ
月 | 過去 3 か月のテスト数 | 過去 3 か月間にテストされた固有の SN の数 |
1月 | 3 | 2 |
2月 | 6 | 4 |
3月 | 8 | 6 |
4月 | 7 | 5 |