cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
RayE
Level III

Generate Delta table to calculate deltas between two temp measurments

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

RayE_3-1769461059715.png

 

the error I get 

RayE_2-1769461006624.png

 

My data table 

RayE_4-1769461096642.png

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Generate Delta table to calculate deltas between two temp measurments

newRow = 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

Jim

View solution in original post

11 REPLIES 11
jthi
Super User

Re: Generate Delta table to calculate deltas between two temp measurments

Could you provide the data table?

-Jarmo
RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

Thanks Jarmo, see attached table

txnelson
Super User

Re: Generate Delta table to calculate deltas between two temp measurments

newRow = 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

Jim
RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

Thanks Jim, I will the new code, I was getting empty table

 

RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

it worked like a charm!, I will try it on a larger dataset, Thank you Jim

RayE_0-1769538263387.png

 

RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

confirmed calc in excel as well, data match.

RayE_1-1769538624444.png

 

RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

Hi 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

 

txnelson
Super User

Re: Generate Delta table to calculate deltas between two temp measurments

Every 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.

Jim
RayE
Level III

Re: Generate Delta table to calculate deltas between two temp measurments

Hi 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

 

Recommended Articles