cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
AAYH
Level II

Rowwise conditonal calculation

I have a table of data with three columns of process data and one column with quality data. I would like to calculate a value (in new columns -each for one of the process parameters) if the process value between two rows are changing. 

So first of all I need JMP to look at each row and then determine whether each of the process variables are changed (if function??).

If changes have occurred then calculate (quality(1)-quality(2))/(process value(1)-process value(2))

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Rowwise conditonal calculation

You can calculate difference between rows using Dif() or Lag().

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("P", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 2])),
	New Column("Q", Numeric, "Continuous", Format("Best", 12), Set Values([3, 3, 6]))
);


dt << New Column("", Numeric, Continuous, Formula(
	difval1 = Dif(:P);
	difval2 = Dif(:Q);
	If(difval1 & difval2,
		difval2 / difval1;
	,
		.
	);
));

You can explore subexpression values from formula editor if needed

jthi_0-1699622022729.png

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Rowwise conditonal calculation

You can calculate difference between rows using Dif() or Lag().

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("P", Numeric, "Continuous", Format("Best", 12), Set Values([1, 1, 2])),
	New Column("Q", Numeric, "Continuous", Format("Best", 12), Set Values([3, 3, 6]))
);


dt << New Column("", Numeric, Continuous, Formula(
	difval1 = Dif(:P);
	difval2 = Dif(:Q);
	If(difval1 & difval2,
		difval2 / difval1;
	,
		.
	);
));

You can explore subexpression values from formula editor if needed

jthi_0-1699622022729.png

 

-Jarmo
AAYH
Level II

Re: Rowwise conditonal calculation

Hi.

 

Thank you for your quick solution. Ìn the script you create  a dt. I have already create a dataset can I refer to this as well?

jthi
Super User

Re: Rowwise conditonal calculation

You can. How you should do it, depends where you get the data table. If you open it from somewhere using Open() is the way to go (see Scripting Index (fround from JMP Help menu) and Scripting Guide for more information regarding scripting).

jthi_0-1699627783780.png

 

-Jarmo
jthi
Super User

Re: Rowwise conditonal calculation

Also you can directly create the formula to your data table, no need to use script editor

	difval1 = Dif(:P);
	difval2 = Dif(:Q);
	If(difval1 & difval2,
		difval2 / difval1;
	,
		.
	);
-Jarmo