Changing the filter in a for loopHi,
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.
dt = Open(path to the file);
For( i = 1, i <= 10, i++,
df = dt << Data Filter(Invisible, Mode( Show( 1 ), Include( 1 ) ),
Add Filter( Columns( Tester ), Where( Tester = testerNames[i] ) ) );
Some analysis
print the report
);
Quality and Process EngineeringRe: Changing the filter in a for loopMove filter outside the for loop and use << Where to change the filter values
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
df = dt << Data Filter(
Mode(Show(1), Include(1)),
Add Filter(Columns(:Name))
);
names = Associative Array(:name) << get keys;
For(i = 1, i <= 10, i++,
df << (Filter Column(:name) << Where(:name == names[i]));
wait(1);
);Re: Changing the filter in a for loop@jthi 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.
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.
Re: Changing the filter in a for loopHi @LoglinearRange8 ,
Although @jthi 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<@jthi 's solution to move the filter outside the for loop and only have the selections inside the for loop.
You might also look into another thread from @Mark_Bailey here that shows how you can script this from the Scripting Index.
I also agree with @Mark_Bailey , this might not be the best approach for automating your workflow. There could be better ways to to perform the data analyses.
Hope this helps!,
DS