<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing the filter in a for loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578943#M78626</link>
    <description>&lt;P&gt;Move filter outside the for loop and use &amp;lt;&amp;lt; Where to change the filter values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
df = dt &amp;lt;&amp;lt; Data Filter(
	Mode(Show(1), Include(1)),
	Add Filter(Columns(:Name))
);
names = Associative Array(:name) &amp;lt;&amp;lt; get keys;
For(i = 1, i &amp;lt;= 10, i++,
	df &amp;lt;&amp;lt; (Filter Column(:name) &amp;lt;&amp;lt; Where(:name == names[i]));
	wait(1);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Dec 2022 16:05:11 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-12-08T16:05:11Z</dc:date>
    <item>
      <title>Changing the filter in a for loop</title>
      <link>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578912#M78624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Using a For Loop, I am trying to do some analysis in JMP and each time a series of rows are filtered for this analysis. My code is similar to the snippet below. The problem is that the filter does not change in each iteration and the filter is implemented only the first time. I tried to figure out a solution by reading the JMP Help PDF, but none of them helped.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open(path to the file);

For( i = 1, i &amp;lt;= 10, i++,
df = dt &amp;lt;&amp;lt; Data Filter(Invisible, Mode( Show( 1 ), Include( 1 ) ), 
Add Filter( Columns( Tester ), Where( Tester = testerNames[i] ) ) );

Some analysis

print the report
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:04:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578912#M78624</guid>
      <dc:creator>LoglinearRange8</dc:creator>
      <dc:date>2023-06-09T16:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the filter in a for loop</title>
      <link>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578943#M78626</link>
      <description>&lt;P&gt;Move filter outside the for loop and use &amp;lt;&amp;lt; Where to change the filter values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
df = dt &amp;lt;&amp;lt; Data Filter(
	Mode(Show(1), Include(1)),
	Add Filter(Columns(:Name))
);
names = Associative Array(:name) &amp;lt;&amp;lt; get keys;
For(i = 1, i &amp;lt;= 10, i++,
	df &amp;lt;&amp;lt; (Filter Column(:name) &amp;lt;&amp;lt; Where(:name == names[i]));
	wait(1);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2022 16:05:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578943#M78626</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-12-08T16:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the filter in a for loop</title>
      <link>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578946#M78628</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;answered your question, but I wonder if it is the best approach, to begin with. You are scripting your analysis so you can use row state functions directly instead of employing a data filter as an intermediary. This approach would select rows that meet a criterion and perform the analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not against your approach, but data filter objects are primarily intended for interactive analysis. They are not the only way to filter your data with a script.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 16:17:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578946#M78628</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-12-08T16:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the filter in a for loop</title>
      <link>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578965#M78633</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/45345"&gt;@LoglinearRange8&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Although&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;has answered your question, I think one of the reasons your code isn't working as expected is because you weren't closing down the Data Filter window. If you add a df&amp;lt;&amp;lt;Close command inside your For Loop it should close down the data filter window (which is invisible, and why you don't see what's happening at each step in the for loop). Once you've created that Data Filter window, it remains open and you need to re-define the filter at each iteration, hence&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;'s solution to move the filter outside the for loop and only have the selections inside the for loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You might also look into another thread from&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/how-to-remove-a-local-data-filter-column/td-p/43345" target="_self"&gt;here&lt;/A&gt; that shows how you can script this from the Scripting Index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I also agree with&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;, this might not be the best approach for automating your workflow. There could be better ways to to perform the data analyses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 16:39:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Changing-the-filter-in-a-for-loop/m-p/578965#M78633</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2022-12-08T16:39:36Z</dc:date>
    </item>
  </channel>
</rss>

