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
abramov1989
Level I

Jmp 14 - count specific occurrence prior another specific value in a column

hey guys

 

i have a column with 2 different strings, A and B.

 

i need to count the occurance of A, before every occurance of B. so i can get a column that representes for every row conatining B, how many rows of A were presented before.

 

atached example table, with manual calculation of the desired column.

 

appreciate a lot any help.

 

 

1 REPLY 1
Highlighted
txnelson
Super User

Re: Jmp 14 - count specific occurrence prior another specific value in a column

Here is one possible way to write the formula.  The attached data table has the formula applied

If( Row() == 1,
	counter = 0;
	result = .;
);
If(
	:Type == "A",
		counter++;
		result = .;,
	:Type == "B",
		result = counter;
		counter = 0;
);
result;
Jim
Article Labels

    There are no labels assigned to this post.