Choose Language Hide Translation Bar
Highlighted
tom_abramov
Level V

Add Favorites to Data Filter with Eval(Substitute(Expr

Hello,

I have a bug with adding Favorites to Data Filter.

I would like that FAVORITECLAUSE will not be a string but expression (more convenient to maitain).

Please assist.

 

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


FAVORITESCLAUSE = Favorites(
	"FAV1"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "M" ),
		Where( :height >= 51 & :height <= 60.952 )
	)),
	"FAV2"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "F" ),
		Where( :height >= 51 & :height <= 60.952 )
	))
);	
	
Eval(
	Substitute(
			Expr(
				dt << Data Filter(
					Location( {-1136, 147} ),
					Add Filter(
						columns( :age, :sex, :height ),
						Display( :age, Size( 178, 102 ), Height( 102 ) )
					),
					_FAVORITESCLAUSE_
				)
			),
		Expr( _FAVORITESCLAUSE_ ), FAVORITESCLAUSE
	)
);


1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ih
ih
Level VII

Re: Add Favorites to Data Filter with Eval(Substitute(Expr

Try wrapping your FAVORITESCLAUSE in Expr() so it doesn't evaluate immediately, and then use Name Expr() when substituting it in order to add the expression defined by FAVORITESCLAUSE without evaluating it.

 

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


FAVORITESCLAUSE = Expr( Favorites(
	"FAV1"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "M" ),
		Where( :height >= 51 & :height <= 60.952 )
	)),
	"FAV2"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "F" ),
		Where( :height >= 51 & :height <= 60.952 )
	))
) );	
	
Eval(
	Substitute(
			Expr(
				dt << Data Filter(
					Location( {-1136, 147} ),
					Add Filter(
						columns( :age, :sex, :height ),
						Display( :age, Size( 178, 102 ), Height( 102 ) )
					),
					_FAVORITESCLAUSE_
				)
			),
		Expr( _FAVORITESCLAUSE_ ) , Name Expr( FAVORITESCLAUSE )
	)
);

 

View solution in original post

2 REPLIES 2
Highlighted
ih
ih
Level VII

Re: Add Favorites to Data Filter with Eval(Substitute(Expr

Try wrapping your FAVORITESCLAUSE in Expr() so it doesn't evaluate immediately, and then use Name Expr() when substituting it in order to add the expression defined by FAVORITESCLAUSE without evaluating it.

 

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


FAVORITESCLAUSE = Expr( Favorites(
	"FAV1"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "M" ),
		Where( :height >= 51 & :height <= 60.952 )
	)),
	"FAV2"(Match( columns( :age, :sex, :height ),
		Where( :age == 14 ), Where( :sex == "F" ),
		Where( :height >= 51 & :height <= 60.952 )
	))
) );	
	
Eval(
	Substitute(
			Expr(
				dt << Data Filter(
					Location( {-1136, 147} ),
					Add Filter(
						columns( :age, :sex, :height ),
						Display( :age, Size( 178, 102 ), Height( 102 ) )
					),
					_FAVORITESCLAUSE_
				)
			),
		Expr( _FAVORITESCLAUSE_ ) , Name Expr( FAVORITESCLAUSE )
	)
);

 

View solution in original post

Highlighted
tom_abramov
Level V

Re: Add Favorites to Data Filter with Eval(Substitute(Expr

Thank you!

Article Labels