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.
Choose Language Hide Translation Bar
kluu
Level II

Calculate difference between 2 group

Hi Everyone,

I am new with jmp.  I have a data table like the below:

index Team value

1        a        5

2        a        12

3        a        20

4        b        5

5        b        22

6        b        6

 

I want to create a new column, "delta", that calculate the differences between the index group by "team", so i would have something like this:

 

index Team value delta

1        a        5        .   

2        a        12      .

3        a        20      .

4        b        5        0

5        b        22      -10

6        b        6        14

 

Could you help with the jsl column formula?

Thanks

Khanh

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Calculate difference between 2 group

Here is a formula that works for your example table.

If( Row() == 1,
	startTeam = :Team;
	theList = {};
	theDelta = .;
);
If( :Team == startTeam,
	Insert Into( theList, :value ),
	If( :Team != Lag( :Team ),
		count = 0
	);
	count++;
	theDelta = theList[count] - :value;
);
theDelta;
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Calculate difference between 2 group

Here is a formula that works for your example table.

If( Row() == 1,
	startTeam = :Team;
	theList = {};
	theDelta = .;
);
If( :Team == startTeam,
	Insert Into( theList, :value ),
	If( :Team != Lag( :Team ),
		count = 0
	);
	count++;
	theDelta = theList[count] - :value;
);
theDelta;
Jim
kluu
Level II

Re: Calculate difference between 2 group

Thank you Jim.  It works

Recommended Articles