This is a fairly simple thing to do.
To do this interactively you would
- Open both data tables
- Go to table one and create a new column called "subcount" with the following formula
If(
Row() == 1, x = 1,
Lag( :Batch no. 1 ) == :Batch no. 1, x++,
x = 1
);
x;
- Go to the second table and create a new column also called "subcount" with a slightly different formula, because of the different column names in the second table
If(
Row() == 1, x = 1,
Lag( :Batch no_2 ) == :Batch no_2, x++,
x = 1
);
x;
- Click on the first data table to make it the active table
- Go to Tables=>Update
- Select the second table as the table to get the updates from
- Select column Batch no. 1 from the first table and column Batch no_2 from the second column to match on
- Select column subcount from the first table and column subcount from the second data table as the second pair of columns to match on
- Click on OK
- Click on the column header for column subcount and then right click and select delete column
- Repeat the above step for the second data table
Below is a script that will perform the same actions as the interactive steps above
Names Default To Here( 1 );
dt1 = Data Table( "untitled 22" );
dt2 = Data Table( "untitled 23" );
dt1 << New Column( "subcount",
formula(
If(
Row() == 1, x = 1,
Lag( :Batch no. 1 ) == :Batch no. 1, x++,
x = 1
);
x;
)
);
dt2 << New Column( "subcount",
formula(
If(
Row() == 1, x = 1,
Lag( :Batch no_2 ) == :Batch no_2, x++,
x = 1
);
x;
)
);
dt1 << Update( With( dt2 ), Match Columns( :Batch no. 1 = :Batch no_2, :subcount = :subcount ) );
dt1 << delete column(subcount);
dt2 << delete column(subcount);
Jim