cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

How to Select values in a column Based on Column Number

I have a column dialog that stores the name of a column into the list "selectedDataPinColumn". I am using a loop to find out which column number that name corresponds to and am referencing the column based on the number found, which works. I am trying to add to a previous selected on the table, and I just cannot seem to get the Select Where function to work with anything other than the hard coded column name, which will not work for me as this need to be dynamic. I have included the main loop below, JMP 16.

For ( i = 1, i <= N Cols (originalTable), i++,
				
				tempColName = Char(Column ( originalTable, i) << Get Name ());
				
				For ( j = 1, j <= N Items (selectedDataPinColumn), j++,
					
					If ( tempColName == Char(selectedDataPinColumn[j]),

						originalTable << Select Where ( Column( originalTable, i ) == "GND" | Column (originalTable, i) == "GND & MeasI" | Column (originalTable, i) == "HIZ" | Column (originalTable, i) == "HiZ"*/, Current Selection( "Extend" ));
						originalTable << Invert Row Selection();
						
						selectedRows = originalTable << Get Selected Rows ();
						
						selectVsandAs << Close Window();
						
						//originalTable << Delete Rows (selectedRows);
						
					);
					
				);
				
			);
1 REPLY 1
jthi
Super User

Re: How to Select values in a column Based on Column Number

It might be enough you you change Column() to  AsColumn() or Column()[] or Column()[Row()]. Also depending on what you are doing, there might be quite a few ways how you could simplify your code (using Contains instead of Or(), For Each instead of For...)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");


i = 1;
dt << Select Where(Contains({"JOE", "F"}, AsColumn(dt, i)), Current Selection("Extend"));

wait(1); // for demo purposes

i = 3;
dt << Select Where(Contains({"JOE", "F"}, Column(dt, i)[]), Current Selection("Extend"));

 

-Jarmo

Recommended Articles