- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Check box data filter
Hi,
I want to have a checkbox where the user can select the option to view the data. I tried using function but something doesn't seem to be correct in my code. Could you please advice?
Names default to here( 1 );
dt = Open( "$SAMPLE_DATA/Time Series/Raleigh Temps.jmp" );
New window(
"Graph with filter",
Data filter context box(
H list box(
V list box(
Text Box( "Enter month:"),
check Box( {"1","2", "3"}, << set(2),
<<SetFunction( Function( {neb},
ldf << (Filter Column( :Month Number ) << Where( :Month Number == ( neb << Get()) ) );
))
),
lb = outline box(
"data filter",
ldf = dt << Data filter(
"Local",
Add Filter(
columns( :Month Number ),
Where( :Month Number == 1 )
)
)
),
<< Padding(
Left(20), Right(20), Top(20), Bottom(20)
)
),
dt << Graph Builder(
Size( 400, 300 ),
Show Control Panel( 0 ),
Variables(
X( :Name( "Month/Year" ) ),
Y( :Temperature ),
Y( :Predicted Temperature, Position( 1 ) )
),
Elements( Line( X, Y( 1 ), Y( 2 ), Legend( 23 ) ) )
);
)
)
);
lb << Visibility("collapse");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
In general I think it works best to fully evaluate exprs within the Where clause that are constant, before you send the message to the data filter. In this small excerpt, I also switched from a Check Box to a Radio Box. The problem with a Check Box is that you can select ranges that may not actually be possible in the filter (select 1,3, but not 2).
radio Box( {"1","2", "3"}, << set(2),
<<SetFunction( Function( {neb},
Eval(EvalExpr(
ldf << (Filter Column( :Month Number ) <<
Where( :Month Number == ( Expr(neb << Get())) ) );
))
))
),
You might consider changing the modeling type for the Month Number in this example to Nominal/Ordinal (either in the data table or just for the filter, in the red-triangle menu). This would give you more flexibility in the Where clause that would support Check Box type behavior, or you may be able to simply use the built-in Check Box and Radio Box modes of the filter. This is a JMP 16 example:
dt = Open( "$SAMPLE_DATA/Time Series/Raleigh Temps.jmp" );
dt << Graph Builder(
Size( 400, 563 ),
Show Control Panel( 0 ),
Variables(
X( :"Month/Year"n ),
Y( :Temperature ),
Y( :Predicted Temperature, Position( 1 ) )
),
Elements( Line( X, Y( 1 ), Y( 2 ), Legend( 23 ) ) ),
Local Data Filter(
Add Filter(
columns( :Month Number ),
Modeling Type( :Month Number, Nominal ),
Where( :Month Number == {1, 3} ),
Display(
:Month Number,
N Items( 5 ),
"Check Box Display",
Find( Set Text( "" ) )
)
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
@danschikore Many Thanks!
Quick question- I want to add an option in radio box "Show All" which will show all the months data. Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
Hi @Jackie_ - If you are using the built-in Radio Box display mode, the "None Selected" is the added option to select all levels. This is the state that column filters start in, and also the state that they return to when you Clear the filter item. When a filter item is "Clear", it does not participate in the filter, and the saved script does not contain a Where clause for that column.
If you are needing to do this from your custom filter display, calling <<Clear should do it for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
Most likely the issue is with the where clause, I would suggest adding reference to checkbox to help you with debugging and see how it behaves and then try to get the function working outside the function. After you get that going as you want, then try to implement it inside the function.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Time Series/Raleigh Temps.jmp");
New Window("Graph with filter",
Data Filter Context Box(
H List Box(
V List Box(
Text Box("Enter month:"),
cb = Check Box({"1", "2", "3"}, // add reference here for easier debugging
<<set(2),
<<SetFunction(
Function({neb},
ldf << (Filter Column(:Month Number) << Where(:Month Number == (neb << Get())))
)
)
),
lb = Outline Box("data filter",
ldf = dt << Data filter("Local", Add Filter(columns(:Month Number), Where(:Month Number == 1)))
),
<<Padding(Left(20), Right(20), Top(20), Bottom(20))
),
dt << Graph Builder(
Size(400, 300),
Show Control Panel(0),
Variables(X(:Name("Month/Year")), Y(:Temperature), Y(:Predicted Temperature, Position(1))),
Elements(Line(X, Y(1), Y(2), Legend(23)))
)
)
)
);
lb << Visibility("collapse");
cb << get(); // returns 0
cb << get(2); // returns 1
cb << Get Selected; // returns selection {"2"}
cb << Get Selected Indices; // returns selection {2}
If you could use Hide and Exclude (or rowstates) here it would be much easier than using local data filter, but this isn't always possible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
I modified the code- added calling function for clear. If I set the data filter to invisible it doesn't filter the rows. I'm not sure what's wrong . I have also attached the data table
Here's what it looks like
Names Default To Here( 1 );
dt = Current Data Table();
New Window( "Graph with filter",
modal,
Data Filter Context Box(
H List Box(
V List Box(
Text Box( "Select Bins:" ),
Radio Box(
{"1", "2", "N", "A","B","All"},
<<SetFunction(
Function( {neb},
Eval( Eval Expr( ldf << (Filter Column( :Bins ) << Where( :Bins == (Expr( neb << Get selected() )) )) ) );
sel = neb << get selected;
Match( sel,
"All",
ldf << clear;
);
)
)
),
lb = Outline Box( "", ldf = dt << Data filter( "Local", invisible, Add Filter( columns( :Bins ), Where( :Bins == 1 ) ) ) ),
<<Padding( Left( 20 ), Right( 20 ), Top( 20 ), Bottom( 20 ) )
),
gb = Graph Builder(
Size( 1000, 592 ),
Show Control Panel( 0 ),
Show Footer( 0 ),
Variables( X( :X coord ), Y( :Y coord ), Group X( :Bins ), Color( :Bins ) ),
Elements( Points( X, Y, Legend( 4 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Wafer Map" ), Image Export Display( Normal )} ),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Bins vs. coord" )} )
)
);
gbr = Report( gb );
gbr[axisbox( 2 )] << Reversed Scale( 1 );
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Check box data filter
Hi @Jackie_ - the invisible option is really only useful for global filters. This option completely removes the display component of the data filters, but local filters depend on the position in the report to determine which reports are being filtered. You can hide the filter in other ways, such as the original visibility option that you used in the initial version of the script:
lb << Visibility("Collapse");