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
chadyoder
Level I

Script to clear a data filter back to original data table

Hello,  I have a large data set that I want to generate multiple types of graphs for.  There is a column with 18 different categories that I want to create a set of graphs for.  So I have this data filter script:

Current Data Table() << Data Filter(

Location ( { 30, 30}),

Mode (Select ( 0), Show (1 ), Include (1)),

Add Filter(

columns (:X),

Where(:x == "A"),

Display (:X, Size (204, 174), List Display)));

That data filter works and I can run my graph builder.  But, then I want to then clear my data filter and change the name from A to B and rerun the graphs for that.  I also want to be able to put all of this into one long script so I can click run and generate all this at one time.  It's a weekly process.  Anyway does anyone know how to do that.  I know there is a clear function for this but I can not figure out how to script that to get it to work.

Any help would be great.

Thanks,

Chad

1 ACCEPTED SOLUTION

Accepted Solutions
chungwei
Staff (Retired)

Re: Script to clear a data filter back to original data table

I used the data table Big Class, and did something like this:

Distribution(

  Automatic Recalc( 1 ),

  Continuous Distribution( Column( :weight ) )

);

value = { 12, 13, 14, 15};

obj = Current Data Table() << Data Filter(

  Location( {30, 30} ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),

  Add Filter( columns( :age ), Where( :age == value[1] ) )

);

for (i=2, i<5, i++,

obj << clear

obj << (filter column (:age) << where (:age==value[i]));

wait(1)

);

View solution in original post

4 REPLIES 4
chungwei
Staff (Retired)

Re: Script to clear a data filter back to original data table

is this what you have in mind ?


value = { 12, 14};

obj = Current Data Table() << Data Filter(

  Location( {30, 30} ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),

  Add Filter( columns( :age ), Where( :age == value[1] ) )

);

obj << clear

obj << (filter column (:age) << where (:age==value[2]));

ian_jmp
Level X

Re: Script to clear a data filter back to original data table

Depending on exactly what is required, an alternative approach may be to manipulate the row states directly:

NamesDefaultToHere(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

// List of 'by' variables

byCols = {:age, :sex};

// Loop over 'by' variables

for(c=1, c<=NItems(byCols), c++,

  // What are the levels of this variable

  levs = AssociativeArray(byCols[c]) << getKeys;

  // Loop over levels

  for(i=1, i<=NItems(levs), i++,

  // Start with a clean slate

  dt << clearRowStates;

  // Template expression to select rows appropriately

  CMD = Expr(dt << selectWhere(byCol != lev));

  // 'Bake in' the current values

  SubstituteInto(CMD, Expr(byCol), byCols[c], Expr(lev), Eval(levs[i]));

  // Finally make the selection

  CMD;

  // Hide and exclude

  dt << Hide << Exclude;

  // Make graphs . . .

  Wait(1);

  );

);

dt << clearRowStates;

If it's Graph Builder specific, you could also take advantage of the fact that it will actually consume a 'by' variable when you launch it.

chadyoder
Level I

Re: Script to clear a data filter back to original data table

That is what I would like to do.  I put the clear statement after my graph builder script and before the new data filter script.  Is that the correct place for it?  If so it did not clear data filter and allow me to change the setting of the filter.  It just stayed the same.

chungwei
Staff (Retired)

Re: Script to clear a data filter back to original data table

I used the data table Big Class, and did something like this:

Distribution(

  Automatic Recalc( 1 ),

  Continuous Distribution( Column( :weight ) )

);

value = { 12, 13, 14, 15};

obj = Current Data Table() << Data Filter(

  Location( {30, 30} ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),

  Add Filter( columns( :age ), Where( :age == value[1] ) )

);

for (i=2, i<5, i++,

obj << clear

obj << (filter column (:age) << where (:age==value[i]));

wait(1)

);