cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
tbidwell
Level III

How do I avoid an error when selecting a row from a filtered table box?

I am running JMP 17.1 and have the script shown below which works thanks to @jthi help.  When I run the script, I get a table box of Big Class.jmp in a window and I can select a row and it returns the values of Height and Weight from the selected row.  In my real world application, I have a much larger table that I'd like to filter down by right-clicking in the window and choosing "Filter Where...".  When I get the filtered table in the Table Box, sometimes the selected row returns the data and other times it returns an error that says "Subscript problem in access or evaluation of 'hvals[/*###*/sel], hvals[/*###*/sel]".  In my example below, I right-click on the Big Class Table Box and Filter by sex == F.

 

Any ideas on how I can retrieve data for each of the rows of the subset table box without an error?

 

names default to here(1);

//run this now
dt = open("$sample_data\big class.jmp", invisible);

rpt = dt << select where(row() <= 10) << get as report;
tb = rpt[Table Box(1)];
tb << Set Selectable Rows();
tb << set row change function( Function( {this}, sel = this << get selected rows  ) );
sel = tb << get row change function;

nw = new window("test", 
	v list box(
		outline box("Big Class", rpt),
		text box("Click 'OK' to choose height and weight"),
		Button box("OK",
			hvals = tb[NumberColBox("height")] << get;
			wvals = tb[NumberColBox("weight")] << get;
			ht = hvals[sel][1];
			wt = wvals[sel][1];	
			print(sel, ht,wt);
		)
	)
);

Below are images of the original table (first 10 rows of Big Class), the Big class table after filtering by sex and choosing the row where the error first occurs, and the error message.  Please note that the script works on the filtered table on the first 5 rows but not on rows 6 or 7.

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How do I avoid an error when selecting a row from a filtered table box?

I suggest you contact JMP support (I can also do it if you wish so) regarding this. There are most likely quite a few different workarounds but here is one which seems to work (using clone box()).

Names Default To Here(1);

//run this now
dt = Open("$sample_data\big class.jmp", invisible);

rpt = dt << select where(Row() <= 10) << get as report;
Close(dt, no save);
tb = rpt[Table Box(1)];
tb << Set Selectable Rows(1);

nw = New Window("test",
	V List Box(
		Outline Box("Big Class", rpt),
		Text Box("Click 'OK' to choose height and weight"),
		Button Box("OK",
			hvals = tb[Number Col Box("height")] << get;
			wvals = tb[Number Col Box("weight")] << get;
			sel = (tb << clone box()) << get selected rows;
			ht = hvals[sel][1];
			wt = wvals[sel][1];
			Print(sel, ht, wt);
		)
	)
);
wait(1);

tb << Filter Where(:sex == "F");

I'm not sure if that cloned box gets stored somewhere, so it might be better to store it into a variable, get the selected rows and then set that variable to missing.

-Jarmo

View solution in original post

5 REPLIES 5
jthi
Super User

Re: How do I avoid an error when selecting a row from a filtered table box?

Seems like a bug where you cannot get those rows which are AFTER filtered rows

Names Default To Here(1);

//run this now
dt = Open("$sample_data\big class.jmp", invisible);

rpt = dt << select where(Row() <= 10) << get as report;
Close(dt, no save);
tb = rpt[Table Box(1)];
tb << Set Selectable Rows(1);

nw = New Window("test",
	V List Box(
		Outline Box("Big Class", rpt),
		Text Box("Click 'OK' to choose height and weight"),
		Button Box("OK",
			hvals = tb[Number Col Box("height")] << get;
			wvals = tb[Number Col Box("weight")] << get;
			sel = tb << get selected rows;
			ht = hvals[sel][1];
			wt = wvals[sel][1];
			Print(sel, ht, wt);
		)
	)
);
wait(1);

tb << Filter Where(:sex == "F");
tb << Set Selected Rows([2]);
sel = tb << get selected rows;
show(sel);

wait(1);

tb << Set Selected Rows([6]);
sel = tb << get selected rows;
show(sel);

wait(1);

tb << Reset Filter;
sel = tb << get selected rows;
show(sel);
-Jarmo
jthi
Super User

Re: How do I avoid an error when selecting a row from a filtered table box?

I suggest you contact JMP support (I can also do it if you wish so) regarding this. There are most likely quite a few different workarounds but here is one which seems to work (using clone box()).

Names Default To Here(1);

//run this now
dt = Open("$sample_data\big class.jmp", invisible);

rpt = dt << select where(Row() <= 10) << get as report;
Close(dt, no save);
tb = rpt[Table Box(1)];
tb << Set Selectable Rows(1);

nw = New Window("test",
	V List Box(
		Outline Box("Big Class", rpt),
		Text Box("Click 'OK' to choose height and weight"),
		Button Box("OK",
			hvals = tb[Number Col Box("height")] << get;
			wvals = tb[Number Col Box("weight")] << get;
			sel = (tb << clone box()) << get selected rows;
			ht = hvals[sel][1];
			wt = wvals[sel][1];
			Print(sel, ht, wt);
		)
	)
);
wait(1);

tb << Filter Where(:sex == "F");

I'm not sure if that cloned box gets stored somewhere, so it might be better to store it into a variable, get the selected rows and then set that variable to missing.

-Jarmo
tbidwell
Level III

Re: How do I avoid an error when selecting a row from a filtered table box?

I will report this to JMP support.  @jthi, thank you so much for all of your help.

jthi
Super User

Re: How do I avoid an error when selecting a row from a filtered table box?

When you get response from support, if they have any workarounds please add them here. Also it might be a good idea to post also the ticket id (if someone has similar question and is linked to this topic, JMP Staff can then lookup that ticket id and possibly check the status).

-Jarmo
tbidwell
Level III

Re: How do I avoid an error when selecting a row from a filtered table box?

The JMP Support ticket is:  TS-00063284