Choose Language Hide Translation Bar
Highlighted
tom_abramov
Level V

Save Data Filter Favorites to the next session

Hi,

Here is the challenge:

The user opens a dashboard. The dashboard contains Row data filter. The creates some favorites ("Add favorites"). He closes the dashboard and when he reopens it next day he want his favorites filter appear in the data filter.

Bottom line, while the user closes the dashboard, I need to save the expression of favorites and paste it with "Eval(Substitute(Expr(" on the next run of the dashboard.

Any idea how and where to save expressions between runs?

Note: Only Favorites have to be saved, not all data filter script.

for example:

	Favorites(
		"FILTER1"(Match( columns( :name, :age, :sex, :height, :weight ),
			Where( :age == {12, 13} ), Where( :sex == "M" )
		)),
		"FILTER2"(Match( columns( :name, :age, :sex, :height, :weight ),
			Where( :sex == "F" ), Where( :height >= 62.875 & :height <= 70 )
		))
	)

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
tom_abramov
Level V

Re: Save Data Filter Favorites to the next session

I have a solution. Thanks.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
df = dt << Data Filter(
	Location( {577, 71} ),
	Add Filter(
		columns( :name, :age, :sex, :height, :weight ),
		Display( :name, Size( 161, 68 ), Height( 68 ), Find( Set Text( "" ) ) ),
		Display( :age, Size( 178, 102 ), Height( 102 ) )
	),
	Favorites(
		"FF1"(Match( columns( :name, :age, :sex, :height, :weight ),
			Where( :age == {13, 14, 15} ),
				Where( :height >= 60.952 & :height <= 70 )
		))
	)
);
//Save Favorites expression to journal
curJur = Open("C:\Journal.jrn");
curJur[ButtonBox(1)] << Delete Box();
df << Save Script to Journal;
curJur << Save Journal("C:\Journal.jrn");
curJur << Close Window(nosave);

//Load Favorites expression from journal
curJur = Open("C:\Journal.jrn");
SavedExpr = curJur[ButtonBox(1)] << Get Function;
FavoriteExpr = Extract Expr( SavedExpr, Favorites( Wild()) );
curJur << Close Window(nosave);

View solution in original post

3 REPLIES 3
Highlighted
gzmorgan0
Super User

Re: Save Data Filter Favorites to the next session

@tom_abramov 

 

I don't have time to write some test code, however, here is the approach I'd take:

 

  • Create your Dashboard with a TextBox with Visibility Collapsed
  • Use and OnClose script to add the Favorites Filter string to this hidden text box.
  • Use an OnOpen or some dashboard object dependency to get the values.

 

You could use a file, if this is for personal use. But if the dashboard is on some shared service, often security prohibits opening external files.

 

Just a starting idea. 

Highlighted
tom_abramov
Level V

Re: Save Data Filter Favorites to the next session

@gzmorgan0 

Thank you.

I thought about OnClose/OnOpen as well, but I have no idea how to save some expression to external file and load this expression after I restart JMP and re-run a dashboard.

May be to Journal?

If you have any idea, please write some really simple example.

For example, save this "Expr (x=5)" and then load it back.

Highlighted
tom_abramov
Level V

Re: Save Data Filter Favorites to the next session

I have a solution. Thanks.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
df = dt << Data Filter(
	Location( {577, 71} ),
	Add Filter(
		columns( :name, :age, :sex, :height, :weight ),
		Display( :name, Size( 161, 68 ), Height( 68 ), Find( Set Text( "" ) ) ),
		Display( :age, Size( 178, 102 ), Height( 102 ) )
	),
	Favorites(
		"FF1"(Match( columns( :name, :age, :sex, :height, :weight ),
			Where( :age == {13, 14, 15} ),
				Where( :height >= 60.952 & :height <= 70 )
		))
	)
);
//Save Favorites expression to journal
curJur = Open("C:\Journal.jrn");
curJur[ButtonBox(1)] << Delete Box();
df << Save Script to Journal;
curJur << Save Journal("C:\Journal.jrn");
curJur << Close Window(nosave);

//Load Favorites expression from journal
curJur = Open("C:\Journal.jrn");
SavedExpr = curJur[ButtonBox(1)] << Get Function;
FavoriteExpr = Extract Expr( SavedExpr, Favorites( Wild()) );
curJur << Close Window(nosave);

View solution in original post

Article Labels