cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

How to get last entry of raw?

I have multiple measurement for a same part number in a raw. How can I get last entry in a one column.

ConfidenceOwl94_1-1728954398637.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: How to get last entry of raw?

this might work:

// make a column to hold results, it will be last column
dt << newcolumn("answer");
for(irow=1,irow<=nrows(dt),irow+=1,
	// assumes columns 1 and 2 and last are NOT data...
	// grab one row at a time...
	vec = dt[irow, 3::(ncols(dt)-1)];
	// get indexes (loc) of non-missing values...pick the right-most (max)
	nonmissindex = max(loc(vec));
	// handle possible edge case (no data)
	value = if(ismissing(nonmissindex),.,vec[nonmissindex]);
	// fill in the answers
	dt:answer[irow] = value;
);

If you turn this into a column formula, you'll want to list the source columns explicitly for table updates and not needing dt.

dt << New Column( "answer",
	formula(
		vec = run_1 || run_2 || run_3 || run_4;
		nonmissindex = Max( Loc( vec ) );
		If( Is Missing( nonmissindex ),
			.  // missing if all missing 
               , //
			vec[nonmissindex]
		);
	)
);

As a formula, the answer column will update when the data changes.

Craige

View solution in original post

txnelson
Super User

Re: How to get last entry of raw?

Here is the formula I cam up with

dt = Current Data Table();
x = Row();
col = Length( Loc( dt[x, Index( 3, 6 )] ) ) + 2;
dt[x, col];
Jim

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: How to get last entry of raw?

this might work:

// make a column to hold results, it will be last column
dt << newcolumn("answer");
for(irow=1,irow<=nrows(dt),irow+=1,
	// assumes columns 1 and 2 and last are NOT data...
	// grab one row at a time...
	vec = dt[irow, 3::(ncols(dt)-1)];
	// get indexes (loc) of non-missing values...pick the right-most (max)
	nonmissindex = max(loc(vec));
	// handle possible edge case (no data)
	value = if(ismissing(nonmissindex),.,vec[nonmissindex]);
	// fill in the answers
	dt:answer[irow] = value;
);

If you turn this into a column formula, you'll want to list the source columns explicitly for table updates and not needing dt.

dt << New Column( "answer",
	formula(
		vec = run_1 || run_2 || run_3 || run_4;
		nonmissindex = Max( Loc( vec ) );
		If( Is Missing( nonmissindex ),
			.  // missing if all missing 
               , //
			vec[nonmissindex]
		);
	)
);

As a formula, the answer column will update when the data changes.

Craige
txnelson
Super User

Re: How to get last entry of raw?

Here is the formula I cam up with

dt = Current Data Table();
x = Row();
col = Length( Loc( dt[x, Index( 3, 6 )] ) ) + 2;
dt[x, col];
Jim

Recommended Articles