I have a data table that combines 2 datasets for 2 temperature for multiple units. Each unit is subjected to 20+ tests at 2 temps.
I need to generate a delta table for each unit, that calculate the delta between temp2 - temp1 as shown in table "Data_Table".
I keep getting the same error after an incomplete delta table is generated shown next

the error I get

My data table

here is my code, if any can help I would really appreciate it
Names Default To Here(1);
dt = Current Data Table();
allCols = dt << Get Column Names(string);
tpColName = allCols[1]; // Always Column 1
dutColName = allCols[2]; // Always Column 2
testCols = {};
For(i = 3, i <= N Items(allCols), i++,
Insert Into(testCols, allCols[i])
);
// 2. Extract Unique Values
Summarize(dt, dutList = By(Column(dt, 2)));
Summarize(dt, tpList = By(Column(dt, 1)));
// 3. Setup Results Table
dt_delta = New Table("DUT Delta Results");
dt_delta << New Column("DUT", Character, Nominal);
dt_delta << New Column("Shift", Character, Nominal);
For(i = 1, i <= N Items(testCols), i++,
dt_delta << New Column(testCols[i] || " Δ", Numeric, Continuous)
);
// 4. Robust Calculation Loop
For(d = 1, d <= N Items(dutList), d++,
currDUT = dutList[d];
For(t = 2, t <= N Items(tpList), t++,
p1 = tpList[t - 1];
p2 = tpList[t];
// This forces a match even if your DUT/TestPoints are numbers
r1Mat = dt << Get Rows Where(
Char(Column(dt, 2)[]) == Char(currDUT) & Char(Column(dt, 1)[]) == Char(p1)
);
r2Mat = dt << Get Rows Where(
Char(Column(dt, 2)[]) == Char(currDUT) & Char(Column(dt, 1)[]) == Char(p2)
);
// Ensure exactly one row found for each point to prevent subscript errors
If(N Rows(r1Mat) > 0 & N Rows(r2Mat) > 0,
row1 = r1Mat[1]; // Explicitly take first found row as integer
row2 = r2Mat[1];
newRow = dt_delta << Add Rows(1);
dt_delta:DUT[newRow] = currDUT;
dt_delta:Shift[newRow] = p2 || " - " || p1;
For(c = 1, c <= N Items(testCols), c++,
colN = testCols[c];
v1 = Column(dt, colN)[row1];
v2 = Column(dt, colN)[row2];
If(!Is Missing(v1) & !Is Missing(v2),
Column(dt_delta, colN || " Δ")[newRow] = v2 - v1
);
);
);
);
);
dt_delta << Bring Window To Front;
Edit (jthi): added JSL formatting