Generate Delta table to calculate deltas between two temp measurmentsI 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
Automation and ScriptingRe: Generate Delta table to calculate deltas between two temp measurmentsCould you provide the data table?
Re: Generate Delta table to calculate deltas between two temp measurmentsnewRow = dt_delta << Add Rows(1);
Does not return the row number. If you change it to:
dt_delta << Add Rows(1);
newRow = nrows(dt_delta);
it will work
Re: Generate Delta table to calculate deltas between two temp measurmentsThanks Jarmo, see attached table
Re: Generate Delta table to calculate deltas between two temp measurmentsThanks Jim, I will the new code, I was getting empty table
Re: Generate Delta table to calculate deltas between two temp measurmentsit worked like a charm!, I will try it on a larger dataset, Thank you Jim

Re: Generate Delta table to calculate deltas between two temp measurmentsconfirmed calc in excel as well, data match.

Re: Generate Delta table to calculate deltas between two temp measurmentsHi Jim, is there a script or feature in JMP that allow me to scale out all numeric columns to include limits; so when I run variability charts, the limits get included . Right now, all graphs are auto scaled based on data only. Thanks
Re: Generate Delta table to calculate deltas between two temp measurmentsEvery column in a JMP data table can have Column Properties set for them. If you right click on the header of a column, you can then select Column Properties, which in turn will display all of the Column Properties that can be set. The 2 items that seem to be what you will need are Spec Limits, and Axis. Once set, they will be used/displayed on all subsequent relevant graphs.
Re: Generate Delta table to calculate deltas between two temp measurmentsHi Jim this may work for for few tests, but I have ~2k tests and it will be hard to do one at a time, is there a way to do script to apply to all tests? thanks
Re: Generate Delta table to calculate deltas between two temp measurmentsYou can script it. Where are your limits coming from?
Re: Generate Delta table to calculate deltas between two temp measurmentsThanks for the reply, I was able to resolve it. btw my limits are normally imported for each column