やあみんな!
以下に示すように、タイムスタンプ列とさまざまなデータ列を含むデータ テーブル 1 がある場合に問題が発生しています。
| タイムスタンプ | A列 | B列 |
| 2021/02/08 午前 11:45 | A1 | B1 |
| 2021/02/08 午後 1:39 | A2 | B2 |
| 2021/02/08 午後 11:37 | A3 | B3 |
| 2021/02/13 12:01 午前 | A4 | B4 |
| 2021/02/13 午後 4:00 | A5 | B5 |
| 2021/02/13 午後 10:22 | A6 | B6 |
| 2021年2月18日午前9時 | A7 | B7 |
| 2021/02/18 午後 12:01 | A8 | B8 |
| 2021/02/21 午前 9:15 | A9 | B9 |
| 2021/02/21 午前 11:50 | A10 | B10 |
| 2021/02/21 午後 3:00 | A11 | B11 |
データ テーブル 2 にもタイムスタンプ列と対応するデータ列があります。
| タイムスタンプ | C列 | D列 |
| 2021/02/08 11:24 午前 | C1 | D1 |
| 2021/02/13 12:07 AM | C2 | D2 |
| 2021/02/18 午前 10:29 | C3 | D3 |
| 2021/02/21 午前 11:16 | C4 | D4 |
これら 2 つのデータ テーブルを結合して、データ テーブル 1 のタイムスタンプ列を保持しますが、データ テーブル 2 の列 C と D をデータ テーブル 1 に結合し、データのタイムスタンプで示された時刻からデータが適用されるようにしたいと考えています。表 2.結果の列は次のようになります。
| タイムスタンプ | A列 | B列 | C列 | D列 |
| 2021/02/08 午前 11:45 | A1 | B1 | C1 | D1 |
| 2021/02/08 午後 1:39 | A2 | B2 | C1 | D1 |
| 2021/02/08 午後 11:37 | A3 | B3 | C1 | D1 |
| 2021/02/13 12:01 午前 | A4 | B4 | C1 | D1 |
| 2021/02/13 午後 4:00 | A5 | B5 | C2 | D2 |
| 2021/02/13 午後 10:22 | A6 | B6 | C2 | D2 |
| 2021年2月18日午前9時 | A7 | B7 | C2 | D2 |
| 2021/02/18 午後 12:01 | A8 | B8 | C3 | D3 |
| 2021/02/21 午前 9:15 | A9 | B9 | C3 | D3 |
| 2021/02/21 午前 11:50 | A10 | B10 | C4 | D4 |
| 2021/02/21 午後 3:00 | A11 | B11 | C4 | D4 |
何かございましたらよろしくお願いいたします。
もちろんあなたは正しいです@txnelson 。 急いで見すぎただけです。 元の返信を編集しました。
@Dan_Obermiller
行のうち 2 行は日付に基づいて一致しません。示されているテーブルの一致は、ターゲット日に最も近い以前の日付に基づいているようです。
あなたの小さな例では、時間ではなく日付に基づいて照合しているように見えます。 代わりにそれが機能する可能性はありますか?
編集: このコメントは無視しても問題ありません。 例をざっと見すぎてしまいました。
これは、例にある一致を複製するスクリプトです。

スクリプトの実際に動作する部分は 20 行未満です。完全を期すために、スクリプトの先頭にオリジナルのサンプル データ テーブルを作成する JSL を含めました。これにより、スクリプトを切り取って貼り付けるだけで、エラーなしで実行できるようになります。
Names Default To Here( 1 );
dt = New Table( "Base",
Add Rows( 11 ),
New Column( "Timestamp",
Numeric,
"Continuous",
Format( "m/d/y h:m", 19 ),
Input Format( "m/d/y h:m" ),
Set Values(
[3695629500, 3695636340, 3695672220, 3696019260, 3696076800, 3696099720, 3696483600, 3696494460, 3696743700,
3696753000, 3696764400]
)
),
New Column( "Column A",
Character( 16 ),
"Nominal",
Set Values( {"A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11"} )
),
New Column( "Column B",
Character( 16 ),
"Nominal",
Set Values( {"B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "B11"} )
)
);
dt2 = New Table( "Match",
Add Rows( 4 ),
New Column( "Timestamp",
Numeric,
"Continuous",
Format( "m/d/y h:m", 19 ),
Input Format( "m/d/y h:m" ),
Set Values( [3695628240, 3696019620, 3696488940, 3696750960] )
),
New Column( "Column C", Character( 16 ), "Nominal", Set Values( {"C1", "C2", "C3", "C4"} ) ),
New Column( "Column D", Character( 16 ), "Nominal", Set Values( {"D1", "D2", "D3", "D4"} ) )
);
// Here is the actual matching code
dt << New Column("TheRow");
dt2 << New Column("TheRow", formula(Row()));
// Find the row in the Match data table that is to be paired with the row
// in the Base data table
For( i = 1, i <= N Rows( dt ), i++,
dt:theRow[i] = Max( dt2 << get rows where( dt2:timestamp <= dt:Timestamp[i] ) )
);
// Update data tables
Data Table( "Base" ) << Update(
With( Data Table( "Match" ) ),
Match Columns( :TheRow = :TheRow )
);
// Delete column: TheRow
Data Table( "Base" ) << Delete Columns( :TheRow );
// Delete column: TheRow
Data Table( "Match" ) << Delete Columns( :TheRow );