Choose Language Hide Translation Bar

## Select Where not working for final loop

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),IsMissing(indv_lmts),IsMissing(indv_lmts)),IsMissing(cusum_lmts),IsMissing(ewma_lmts)),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,:Batch Details=rw,:Date Processed=rw,:Paste Type=rw,:Process Name=rw,:Process Value=rw});

);

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

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);

hb<<Append(TB);

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
Highlighted

## Re: Select Where not working for final loop

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 4

## Re: Select Where not working for final loop

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

## Re: Select Where not working for final loop

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);

);

);

## Re: Select Where not working for final loop

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.

Highlighted

## Re: Select Where not working for final loop

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!!
{"ft_lang_label":"__label__en","ft_lang_prob":0.69278383,"math_prob":0.9172633,"size":6043,"snap":"2019-26-2019-30","text_gpt3_token_len":1680,"char_repetition_ratio":0.09057791,"word_repetition_ratio":0.33933517,"special_character_ratio":0.28959125,"punctuation_ratio":0.2071651,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98765117,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-07-18T11:45:59Z\",\"WARC-Record-ID\":\"<urn:uuid:8b3c6dde-c46a-444f-84e3-532602e68bd0>\",\"Content-Length\":\"813392\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:04024718-c6e4-4769-989a-2d00b36537b5>\",\"WARC-Concurrent-To\":\"<urn:uuid:467b8e5d-cf82-4b5c-8ec2-366a5254da55>\",\"WARC-IP-Address\":\"208.74.205.23\",\"WARC-Target-URI\":\"https://community.jmp.com/t5/Discussions/Select-Where-not-working-for-final-loop/m-p/13735/highlight/true\",\"WARC-Payload-Digest\":\"sha1:GIIIVCO3YY7HY4DDSC45XQCSDFEIOIY7\",\"WARC-Block-Digest\":\"sha1:JPEYXIMKNXQJHY5UI2CWTOW3OH56ANG3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-30/CC-MAIN-2019-30_segments_1563195525627.38_warc_CC-MAIN-20190718104512-20190718130512-00417.warc.gz\"}"}