cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
LauraW
Level I

How do you write a column formula which can group by rows defined by another column?

Hi,

I would like to be able to write column formulae which can perform various column formula functions within groups defined by rows in, for example, a column called 'group'. There are various mentions of the 'group by' button when using gemini, but I cannot find this. 

 

For example, I would like to calculate the first cycle in the below table when the retention first passes 60 % (cycle where retention <= 60 %) for each group, A, B, and C.

 

How can I go about doing this? Thanks for the help

 

My JMP version is JMP18 .

 

LauraW_2-1757346064123.png

 

 

 

 

2 REPLIES 2

Re: How do you write a column formula which can group by rows defined by another column?

Here's what I came up with.

 

g = :Group[Row()];
Min( :Cycle[Where( :Group == g & :Retention <= 60 )] );
jthi
Super User

Re: How do you write a column formula which can group by rows defined by another column?

Here are few examples using my example table

 

Column 4:

:C[Col Min(If(:R <= 60, Row(), .), :G)]

If your data is always in order (by Cycle and Retention) and Retention always reaches 60, using :C[] could be unnecessary and you could calculate the row in "reverse" by calculating how many items are above 60, Column 5:

Col Sum(:R > 60, :G) + 1

jthi_1-1757347794849.png

 

Edit: You could also combine Col Min and Col Number

m = Col Sum(:R <= 60, :G);
If(m > 0,
	Col Number(:G, :G) - m + 1;
,
	.
);
-Jarmo

Recommended Articles