cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

2 REPLIES 2
mmarchandFSLR
Level VI

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