cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
LargeElk892
Level II

How to increment based on empty rows

Hi,

I'd like to create a new column formula that increments (1, 2, 3....) only when empty rows are found (e.g. column 7 below). 

Would you have a solution?

Thank you

LargeElk892_0-1710330375703.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to increment based on empty rows

Here is one way to handle your issue.  Assuming that all of your columns are numeric, this will work

As Constant(
	count = 1;
	lagFlag = 0;
	dt = Current Data Table();
);
If( Is Missing( Sum( dt[Row(), 0] ) ) == 0,
	If( lagFlag == 1,
		count++;
		lagFlag = 0;
	)
,
	lagFlag = 1
);

If( lagFlag == 0, count );
Jim

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to increment based on empty rows

Using formula with Lag() is most likely easiest option. Could you provide example with the result you want to have?

-Jarmo
txnelson
Super User

Re: How to increment based on empty rows

Here is one way to handle your issue.  Assuming that all of your columns are numeric, this will work

As Constant(
	count = 1;
	lagFlag = 0;
	dt = Current Data Table();
);
If( Is Missing( Sum( dt[Row(), 0] ) ) == 0,
	If( lagFlag == 1,
		count++;
		lagFlag = 0;
	)
,
	lagFlag = 1
);

If( lagFlag == 0, count );
Jim
LargeElk892
Level II

Re: How to increment based on empty rows

Thank you very much Jim! I took me quite some time to go through each block to understand the logic but I finally got it :D

Recommended Articles