cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Cathal
Level II

Copying Saved Local Data Filter Script from to Data Table to Other Platforms

Hi, 

I have two problems related to using the local data filter within JSL. I'm using JMP 17.

I'm designing a script where a user is prompted to select from a list that gets passed to a local data filter within a Graph Builder object.  This part is fine but once the graph opens I want to save the local data filter to the main data table. The JMP log doesn't record this when I do it manually so I'm not what's the way script this. I've read the scripting index on the "Copy Local Data Filter()" and Paste Local Data Filter()" functions but not that's not exactly what I want. So my first problem is how does one save the local data filter script from a report window to the main data table?

My second problem is how to reuse that filter. I have another script which creates a different report but will use the same local data filter. I've experimented with using Get Table Property() function on the saved Local Data Filter script but that doesn't seem to apply properly to the new report window. 

I understand that consolidating the two scripts into one big script would solve my problems, however, I've separated it to simplify the user experience. It's not ideal but I think my idea could work but I've figure it out on my own. I would greatly appreciate if anyone could help me troubleshoot these problems. 

Kind regards,

Cathal

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Car Poll.jmp" );

// First graph
obj1 = dt << Distribution(
	Nominal Distribution( Column( :country ) ),
	Local Data Filter(
		Add Filter( columns( :sex ), Where( :sex == "Female" ) ),
		Mode( Show( 1 ), Include( 1 ) )
	)
);

// How to save "Local Data Filter" to data table?

// Manually add filter
dt << New Script( "Local Data Filter",
Local Data Filter( Add Filter( columns( :sex ), Where( :sex == "Female" ) ) )
);

// Second graph
obj2 = dt << Distribution(
	Stack( 1 ),
	Nominal Distribution(
		Column( :marital status ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	),
);

// Get local data filter
filter = dt << Get Table Property( "Local Data Filter" );

// How to apply filter to obj2?

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Copying Saved Local Data Filter Script from to Data Table to Other Platforms

One way

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Car Poll.jmp" );

// First graph
obj1 = dt << Distribution(
	Nominal Distribution( Column( :country ) )
);

ldf = obj1 << Local Data Filter(
	Add Filter( columns( :sex ), Where( :sex == "Female" ) ),
	Mode( Show( 1 ), Include( 1 ) )
);
ldf << Save Script to Data Table("Local Data Filter");


obj2 = dt << Distribution(
	Stack( 1 ),
	Nominal Distribution(
		Column( :marital status ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	),
);

ldf_script = dt << Get Script("Local Data Filter");

Eval(EvalExpr(
	Send(obj2, Expr(Name Expr(ldf_script)));
));
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Copying Saved Local Data Filter Script from to Data Table to Other Platforms

One way

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Car Poll.jmp" );

// First graph
obj1 = dt << Distribution(
	Nominal Distribution( Column( :country ) )
);

ldf = obj1 << Local Data Filter(
	Add Filter( columns( :sex ), Where( :sex == "Female" ) ),
	Mode( Show( 1 ), Include( 1 ) )
);
ldf << Save Script to Data Table("Local Data Filter");


obj2 = dt << Distribution(
	Stack( 1 ),
	Nominal Distribution(
		Column( :marital status ),
		Horizontal Layout( 1 ),
		Vertical( 0 )
	),
);

ldf_script = dt << Get Script("Local Data Filter");

Eval(EvalExpr(
	Send(obj2, Expr(Name Expr(ldf_script)));
));
-Jarmo
Cathal
Level II

Re: Copying Saved Local Data Filter Script from to Data Table to Other Platforms

Hi Jarmo, that works! Thanks a million :)

Recommended Articles