Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
eldad_galili
Level II

Grouping Data

Hi,

 

I would like to group data as the attached image.

whenever there is a "No" the result will be a 0.

When ever there is a "Yes" the result will be a running number (1,2,3...) for each group.

 

How do I implement this in a formula (or script?).

 

Thank you very much.

 

 

 

Group.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Grouping Data

Copy this expression and paste it into the Formula Editor for the Grouping column:

 

If(
	Row() == 1,
		temp = :Y == "Yes";
		temp;,
	:Y == "Yes" & Lag( :Y ) == "No",
		temp++;
		temp;,
	:Y == "Yes", temp,
	0
)

 

Change the name of Y to the original data column.

Learn it once, use it forever!

View solution in original post

2 REPLIES 2
Highlighted

Re: Grouping Data

Copy this expression and paste it into the Formula Editor for the Grouping column:

 

If(
	Row() == 1,
		temp = :Y == "Yes";
		temp;,
	:Y == "Yes" & Lag( :Y ) == "No",
		temp++;
		temp;,
	:Y == "Yes", temp,
	0
)

 

Change the name of Y to the original data column.

Learn it once, use it forever!

View solution in original post

Highlighted
eldad_galili
Level II

Re: Grouping Data

Thank you very much