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

Comparision in Select Where () statement

Hi all,
I have extensively searched this website and I think it's an easy solution, but for some reason I cannot get it to work and I have been stuck with it for 2 days.

In the below script I ask the user which part of specific column he would like to select. For example where the column has the value 8. (the column can have values from 1 up to 8). That I would like to select the rows with this value in this column and create a new dt where I create specific graphs with only this subset of the datatable.

 

It creates the subset table with the name with the number I have filled in the text box. It shows me what number I have filled in i.e. XNo = "8"; But the Select where ( Column == XNO) does not work. It does not give me an error, it just does not select the specific rows or makes the graph. It makes a new data table with the same name as the datatable I refer to.

 

If I fill in Select where (column == "8") or Select where( column == it works. I just want that 8 to be variable and that the operater can fill this in himself.

 

dt = current data table();
 
col = column(dt,"MILL_X");
col_name_list = dt << get column names( string );
 
rdata = New Window( "Which part do you want to check?",
    <<modal,
    <<return result,
    X = Text Edit Box( "Which part?" ),
    text box("Click OK to save"),
    Button box("OK",
XNo = X << Get Text),
    Button Box ("Cancel");
);
 
Show( XNo ); //Shows me the string that was given i.e. if I fill in 8 it shows me --> XNo = "8";
 
//Selected desired rows based on values on column
dt << Row Selection(
Select where( :MILL_X == XNo ),  // <--- This does not work it selects the entire dt instead of the selected value from the column. If I fill in :MILL_X == 8 it works. But only for number 8.
Dialog( Edit( Equal( Source Column( col ) ) ), Keep dialog open( 0 ) )
);
 
Subset( (Selected Rows), Output Table Name( "X " || Char(ColletNo) || " inspection" ) );
 
// Create the desired graph using the selected rows
Distribution( 
Continuous Distribution( 
Column( :"Y (µm)"n ),
Process Capability( LSL( -15 ), Target( 0 ), USL( 15 ) )
)
);
 
// Optionally, you can customize the graph further here
// For example, adding additional elements or formatting options
dt << clear select;
dt << clear column selection;
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Comparision in Select Where () statement

Try converting XNo to number (Num(XNo) OR use number edit box. You might also have to modify your column reference a bit (add [] to comparison). Below is example using Big Class table, use values between 12-17 to test

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
 
col = Column(dt, "age");
col_name_list = dt << get column names(string);

rdata = New Window( "Which part do you want to check?",
    <<modal,
    <<return result,
    X = Text Edit Box( "Which part?" ),
    text box("Click OK to save"),
    Button box("OK",
		XNo = X << Get Text
	),
    Button Box ("Cancel");
);
 
Show(XNo); //Shows me the string that was given i.e. if I fill in 8 it shows me --> XNo = "8";
 
//Selected desired rows based on values on column
dt << Select Where(col[] == Num(XNo));
dt_subset = dt << Subset(Selected Rows);
dt << clear select;
 

If there are specific values allowed, you could also modify your selector to be something which only lets user pick specific ones BUT start by getting this version working and then consider those options.

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Comparision in Select Where () statement

Try converting XNo to number (Num(XNo) OR use number edit box. You might also have to modify your column reference a bit (add [] to comparison). Below is example using Big Class table, use values between 12-17 to test

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
 
col = Column(dt, "age");
col_name_list = dt << get column names(string);

rdata = New Window( "Which part do you want to check?",
    <<modal,
    <<return result,
    X = Text Edit Box( "Which part?" ),
    text box("Click OK to save"),
    Button box("OK",
		XNo = X << Get Text
	),
    Button Box ("Cancel");
);
 
Show(XNo); //Shows me the string that was given i.e. if I fill in 8 it shows me --> XNo = "8";
 
//Selected desired rows based on values on column
dt << Select Where(col[] == Num(XNo));
dt_subset = dt << Subset(Selected Rows);
dt << clear select;
 

If there are specific values allowed, you could also modify your selector to be something which only lets user pick specific ones BUT start by getting this version working and then consider those options.

-Jarmo

Re: Comparision in Select Where () statement

This is not the solution specifically but I just found out that the column needs to be Ordinal (or atleast not be continuous). Now I just have to create it in such a way that I still get all my other columns instead of only the age column. I will update when I have the correct fix, but thanks for this. I knew it was something dumb that was not working.

Re: Comparision in Select Where () statement

I have no idea why it didn't work before, because I have tried the Num() statement before and also the col[]. Maybe I didn't do them at the same time, I don't know, tried many iteration but it is working now. Even changing the column to continous is not necessary. Only thing that I haven't tried before which is in your script is the "Names Default to here(1);" line.