cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Ksrzg01
Level I

Evaluating Dif Function by Column

I'm trying to evaluate the difference between two rows using the "Dif" function; however, the evaluation is continuous and has no regard for other columns. For example, with the "Big Class" DT I run the script below, but it will still compute the weight difference between a male and female. Is there any way around this?

 

dt = Current Data Table();

dt << Sort( By( :age, :sex ), Order( Ascending, Ascending ) );

dt << New Column("Weight Delta", Formula(Dif(:weight)));
1 REPLY 1
txnelson
Super User

Re: Evaluating Dif Function by Column

I believe this formula will do what you want.

If( :sex == Lag( :sex ),
	Dif( :weight ),
	.
)
Jim