cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-85236%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C3%89valuation%20de%20la%20fonction%20Dif%20par%20colonne%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-85236%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'essaie%20d'%C3%A9valuer%20la%20diff%C3%A9rence%20entre%20deux%20lignes%20%C3%A0%20l'aide%20de%20la%20fonction%20%22Dif%22%3B%20Cependant%2C%20l'%C3%A9valuation%20est%20continue%20et%20ne%20tient%20pas%20compte%20des%20autres%20colonnes.%20Par%20exemple%2C%20avec%20le%20%22Big%20Class%22%20DT%2C%20je%20lance%20le%20script%20ci-dessous%2C%20mais%20il%20calcule%20toujours%20la%20diff%C3%A9rence%20de%20poids%20entre%20un%20homme%20et%20une%20femme.%20Y%20a-t-il%20un%20moyen%20de%20contourner%20cela%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Current%20Data%20Table()%3B%0A%0Adt%20%26lt%3B%26lt%3B%20Sort(%20By(%20%3Aage%2C%20%3Asex%20)%2C%20Order(%20Ascending%2C%20Ascending%20)%20)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22Weight%20Delta%22%2C%20Formula(Dif(%3Aweight)))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-85261%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%C3%A9valuation%20de%20la%20fonction%20DIF%20par%20colonne%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-85261%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJe%20crois%20que%20cette%20formule%20fera%20ce%20que%20vous%20voulez.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20%3Asex%20%3D%3D%20Lag(%20%3Asex%20)%2C%0A%20Dif(%20%3Aweight%20)%2C%0A%20.%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
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

Recommended Articles