cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

Loop for Deleting Rows

I have a loop for deleting rows where the column value isn't what I want

When I run the loop I keep the first set of rows meeting my specifications then it deletes all other rows. I am importing from an excel file and it has several rows in succession of what I want then a gap with other data then later another several. I only get the first set

N_loop = N Rows(dt_a);
i_loop = 0;

While(N_loop > i_loop,
	If( And(dt_a:Column 7[N_loop] != "example 1", dt_a:Column 7[N_loop] != "example 2"),
		dt_a << Delete Row(N_loop)
	);
	N_loop = N_loop - 1
);

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

View solution in original post

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim

View solution in original post

2 REPLIES 2
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim

Recommended Articles