Subscribe Bookmark RSS Feed

Select Where not working for final loop

vs90

Community Trekker

Joined:

Jun 16, 2015

Hello,

I'm trying to create a subset table and then show it in a report for different process column values. In this case there are 12 total process values and script working fine for 11 of them and showing the subset result correctly but for final value it is selecting all rows. Don't know why. Tried too many things but not able to figure it out.

Code:

plot=Function({lmts,pmt_path,flg,ppath,hpath},

param_dt=Open(pmt_path,"invisible");

param_summ=param_dt<<Summary(Invisible,

Group(:Group By,:Process,:Sample Label,:By))<<Show Window(0);

For(q=11,q<=NRow(param_summ),q++,Current Data Table(param_summ);

obj=New Window("Trend Analysis Report "||Long Date(Today()),

vlb=V list Box()

);obj<<Show Window(0);

col1=:Group By[q];col2=:Process[q];col3=:Sample Label[q];col4=:By[q];

Current Data Table(lmts);

clms=lmts<<Get Column Names(String);

Remove From(clms,1,3);

Current Data Table(dt);

summ_dt=dt<<Summary(Invisible,Group(As Name(col1),As Name(col2),As Name(col3),As Name(col4)));srt_summ=summ_dt<<Sort(Invisible,By(As Name(col3)),Order(Ascending));

srt_summ<<select where(!Contains(Loc Nonmissing(srt_summ<<get as matrix),Row()));srt_summ<<Delete Rows;srt_summ<<Delete Columns(N Rows);

For(t=1,t<=N Items(clms),t++,Current Data Table(lmts);

indv_lmts=As Column(clms[t])[lmts<<Get Rows Where(:Parameter==col2 & :Chart Type=="Individual")];

cusum_lmts=As Column(clms[t])[lmts<<Get Rows Where(:Parameter==col2 & :Chart Type=="CUSUM")];

ewma_lmts=As Column(clms[t])[lmts<<Get Rows Where(:Parameter==col2 & :Chart Type=="EWMA")];

If(

And(OR(IsMissing(indv_lmts[5]),IsMissing(indv_lmts[6]),IsMissing(indv_lmts[7])),IsMissing(cusum_lmts[5]),IsMissing(ewma_lmts[5])),Continue(),

display(srt_summ,col1,col2,col3,col4,clms[t],indv_lmts,cusum_lmts,ewma_lmts);

);

);

For(y=1,y<=N Items(rws),y++,

rw=rws[y];

tr<<AddRows({:Test Number=rw[1],:Batch Details=rw[2],:Date Processed=rw[3],:Paste Type=rw[4],:Process Name=rw[5],:Process Value=rw[6]});

);

Remove From(rws,1,N Items(rws));

add_win=New Window("",Current Data Table(dt);

summ_mn=dt<<Summary(Invisible,Group(As Name(col1),As Name(col4)),Mean(As Name(col2)));Current Data Table(summ_mn);

hb=H List Box(

Oneway(

Y(Column Name(4)),

X(Eval(NameExpr(col4))),

All Pairs(1,LSD Threshold Matrix(0),Ordered Differences Report(0)),Means and Std Dev(1),Comparison Circles(1),Points Jittered(1),Mean Error Bars(0),Std Dev Lines(0),Grand Mean(0)

);

);

);

tr<<Select Where(:Process Name==col2);tr1=tr<<Subset(Selected);show(tr<<Get Selected Rows);

TB=Table Box(

Number Col Box("Test Number",(Column(tr1,"Test Number")<<get values)),String Col Box("Batch Number",(Column(tr1,"Batch Details")<<get values)),

String Col Box("Paste Type",(Column(tr1,"Paste Type")<<get values)),String Col Box("Process Name",(Column(tr1,"Process Name")<<get values)),

Number Col Box("Process Value",(Column(tr1,"Process Value")<<get values),<<set format(6,1)),<<table style("Heading Separator")

);Close(tr1,No Save);

TB<<set shade alternate rows(1);

hb<<Append(TB);

vlb<<Append(add_win);add_win<<Close Window;

nm=Substitute(col2,"/"," Per ");

If(

flg=="old",obj<<Save PDF(ppath||"/"||nm||".pdf");obj<<Save Interactive HTML(hpath||"/"||nm||".htm"),

flg=="old_new_lim",obj<<Save PDF(ppath||"/"||nm||".pdf");obj<<Save Interactive HTML(hpath||"/"||nm||".htm"),

flg=="new",obj<<Save PDF(ppath||"/"||nm||".pdf");obj<<Save Interactive HTML(hpath||"/"||nm||".htm");

);

obj<<Close Window;

);

);

Red line is where it is selecting in code above.

The show command next to it is giving this output in log:

tr << Get Selected Rows = [](0, 1);

Any help/guidance would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

After following each step of my code and extensive research for past 4 days.....I figured it out as the column value stored in table which was being compare to the other table's column value in this particular line: tr<<Select Where(:Process Name==col2);

i.e. col2 for last loop is" IgG % Recovery (ISB to FSB)" and Process Name is" IgG % Recovery(ISB to FSB)"........

By just looking at it's difficult to figure out the difference which was happening with me but fortunate enough today got it working now.

Actually there is a space between Recovery and parenthesis for col2 but NONE for Process Name which was causing trouble.

I'm sorry folks for wasting your time for this. Thanks indeed for giving it a thought though. My Bad!!

4 REPLIES
vs90

Community Trekker

Joined:

Jun 16, 2015

Please let me know if code seems to be confusing!! Still I mention few key things related to this.

tr is the table in which test results based on a IR control chart  being stored using rws list which I'm deleting after saving results for particular process value.

pmroz

Super User

Joined:

Jun 23, 2011

If SELECT WHERE doesn't find any matching rows you'll get the entire table.  A safer approach is to use GET ROWS WHERE.  That will return a matrix; check it to see if any rows were returned.  If yes, then do your subset logic. 

Here's an example:

dt = open("$sample_data\Big Class.jmp");

age_list = {12, 13, 18};

for (i = 1, i <= nitems(age_list), i++,

     one_age = age_list[i];

     age_rows = dt << get rows where(:Age == one_age);

     if (nrows(age_rows) > 0,

           dt << select rows(age_rows);

           dt << subset(selected);

           wait(0);

           dt << clear select;

           show(one_age, age_rows);

     );

);

vs90

Community Trekker

Joined:

Jun 16, 2015

Thanks PMroz!!

I had tried this also but no change at all. It is the case when last loop is running, earlier to that no problem. Only for last counter it's not selecting anything.

Solution

After following each step of my code and extensive research for past 4 days.....I figured it out as the column value stored in table which was being compare to the other table's column value in this particular line: tr<<Select Where(:Process Name==col2);

i.e. col2 for last loop is" IgG % Recovery (ISB to FSB)" and Process Name is" IgG % Recovery(ISB to FSB)"........

By just looking at it's difficult to figure out the difference which was happening with me but fortunate enough today got it working now.

Actually there is a space between Recovery and parenthesis for col2 but NONE for Process Name which was causing trouble.

I'm sorry folks for wasting your time for this. Thanks indeed for giving it a thought though. My Bad!!