cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
ausername
Level II

Nested/Multiple Data Filter Context Box

 ::edit:: Added a comment in the code and included a screenshot to help visualize.

 

Is it possible to do nested filter context boxes or to generate something that effectively does the same thing? Basically I want a set of parent filters that apply to all plots in a report. The reports within that plot need their own particular filters to limit the data they display.

 

I have an interactive report layed like this:

(1) An H List box divided into two columns.

    (A) The first column contains a set of filters that apply to anything in the second column.

    (B) The second column contains a tab box with multiple tabs for different "tool types."

         (i) Each tab contains an h list box with a column of variabiity charts for each "tool" of a given type. Each column needs its own filter to limit which "tool" it displays.

              (a) This filter is hard coded based on a list, but the VarCharts need to update based on the filters in (A).

 

What I am finding is that if I put a where() within the variability chart, it ignores the filters in (A). I then tried nesting filter context boxes, but this doesn't seem to work. The new filters show up, but only the parent-most filter actually does anything. 

 

Logger.JPG

 

I attempted to create a stripped-down/anonymized version of my code, so there may be some typos:

 

myRootPath = "C:\Log_Testing\";
myLogPath = myRootPath;
myReportPath = myRootPath || "Report\";
mypath = myRootPath || "Logs\";

// I tools to plot
// format: ToolID
iTools = {"i1", "i5"};

// P tools to plot
// format: ToolID
pTools = {"p1", "p2"};

Set Current Directory( mypath );

mainDt = Open( myLogPath || "Log.jmp" );

Batch Interactive( 1 );  //Batch mode
dt_name = mainDt << get name();
dt_path = myLogPath;
mainDt << Clear Select;

filterContextBox = Data Filter Context Box();

spcWin = New Window( dt_name || "_VarCharts", filterContextBox );

filterBox = H List Box(
	mainDt << Data Filter(
			//Conditional,
		Local,
		Add Filter(
			columns( :WW, :D ),
			Display( :WW, Blocks Display ),
			Display( :D, Blocks Display ), 

		),
		Mode( Select( 0 ), Show( 1 ), Include( 1 ) ), 
	)
);
	
filterContextBox << Append( filterbox );
filterBox << Append( tb = Tab Box() );
tb << Add( "P", hPTab = H List Box() );
tb << Add( "I", hITab = H List Box() );

numPTools = N Items( pTools );
numITools = N Items( iTools );

//Create P Plots
For( j = 1, j <= numPTools, j++, 
	
	hPTab << Append( vToolBox = V List Box() );
	
	vToolBox << Append( toolTab = Outline Box( pTools[j] ) );
	
	ycol = "VariableName";
	parseName = "Variability Chart for " || ycol;
	toolTab << append(
		NewChart = Variability Chart(
			Y( Column( ycol ) ),
			X( :WW, :D ),
			Max Iter( 100 ),
			Conv Limit( 0.00000001 ),
			Number Integration Abscissas( 128 ),
			Number Function Evals( 65536 ),
			Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),
			Connect Cell Means( 1 ),
			Std Dev Chart( 0 ),
			Points Jittered( 0 ),
			AIAG Labels( 0 ),
			Automatic Recalc( 1 ),
/*If the next line isn't commented out, it ignores the local filter and only uses this one. I need both. */
Where( :ToolID == pTools[j] ); SendToReport( Dispatch( {}, "Variability Gauge", OutlineBox, {Set Title( "" )} ), Dispatch( {parseName}, "2", ScaleBox( 2 ), {Format( "Fixed Dec", 4, 0 ), Min( 0 )} ), Dispatch( {parseName}, "Group Means", StringColBox, {Visibility( "Collapse" )} ), Dispatch( {parseName}, "", PlotColBox, {Visibility( "Collapse" )} ) ) ) ); );
 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nested/Multiple Data Filter Context Box

I've attached two examples of similar layouts to what you describe:

 

SFCrimeNestedFilter.jsl demonstrates how to nest the Data Filter Context Box to get a cascading / hierarchical behavior in the filters.  This approach works in JMP 10+, though the syntax that I use for the Tab Box is JMP 13+.

 

SFCrimeFilterWithWhere.jsl replaces the inner filter with a Where() clause for each report.  This type of layout works in JMP 14 but did not work in prior releases.  The issue is that the filter is using the full table, while the report is using a subset table.

 

I hope this helps!

View solution in original post

11 REPLIES 11
txnelson
Super User

Re: Nested/Multiple Data Filter Context Box

I believe I understand what you want.  Here is an example, taken directly from the Scripting Index

     Help==>Scripting Index==>DataFilterSourceBox

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Selection Filter",
	Data Filter Context Box(
		H List Box(
			dfsb =
			Data Filter Source Box(
				Graph Builder(
					Size( 208, 207 ),
					Show Control Panel( 0 ),
					Show Legend( 0 ),
					Variables( X( :age ) ),
					Elements(
						Bar( X, Legend( 3 ) )
					),
					SendToReport(
						Dispatch(
							{},
							"Graph Builder",
							OutlineBox,
							{Set Title( "Filter" )}
						)
					)
				)
			),
			Platform(
				Current Data Table(),
				Bubble Plot(
					X( :weight ),
					Y( :height ),
					Sizes( :age ),
					Title Position( 0, 0 )
				)
			)
		)
	)
);

Based upon your "Clicked On" selections in one graph, it filters another graph

Jim
ausername
Level II

Re: Nested/Multiple Data Filter Context Box

Thanks Jim! Unless I'm misunderstanding/overlooking something, this is only filtering the second graph based on the first. How do I filter the second graph in addition to the first?

 

i.e. I want the second graph filtered based on the first, but in addition, I only want a subset of the data in the first filter.

 

Effectively what I want is to add "Where( :ToolID == pTools[j] );" to the Variability chart, but if I do this then it completely ignores the Data Filter Source Box (or in my case the local data filter). I actually spent a long time trying to figure out what I was doing wrong with the Data Filter Source Box only to realize it worked once I removed the above "where" line from the Variability Charts.

txnelson
Super User

Re: Nested/Multiple Data Filter Context Box

Here is an example from a Discussion that I had concerning a 2 Level Filter.  It is an expansion on the example I provided in my last post.

Names Default To Here( 1 );

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

New Window( "Shared Local Filter",

       Data Filter Context Box(

              H List Box(

                     Data Filter Source Box(

                           H List Box(

                   Graph Builder(

                        Size( 208, 207 ),

                        Show Control Panel( 0 ),

                        Show Legend( 0 ),

                        Variables( X( :age ) ),

                        Elements( Bar( X, Legend( 3 ) ) ),

                        SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Filter" )} ) )

                    ),

                                    Data Filter Source Box(

                        Graph Builder(

                            Size( 208, 207 ),

                            Show Control Panel( 0 ),

                            Show Legend( 0 ),

                            Variables( X( :sex ) ),

                            Elements( Bar( X, Legend( 3 ) ) ),

                            SendToReport(

                                Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Filter" )} )

                            )

                        )

                    )

                )

            ),

                     Platform(

                           Current Data Table(),

                   Bubble Plot( X( :weight ), Y( :height ), Sizes( :age ), Title Position( 0, 0 ) )

           )

       )

    )

);
Jim
ausername
Level II

Re: Nested/Multiple Data Filter Context Box

Can you apply different sub-filters to different plots with this method? It seems all plots will receive the same filters.

 

I need a single primary filter with a series of independent (invisible) sub-filters applied to different sets of plots. I've updated my original post with a commented-out "where" filter to better convey this.

txnelson
Super User

Re: Nested/Multiple Data Filter Context Box

I can not definatively say yes, but if you look at the structure of the code I provided, I can imagine being able to expand on it to support your structure.

 

I would take the sample, and see if you can make it branch to two different filtering graphs at the second level of filters.

Jim
ausername
Level II

Re: Nested/Multiple Data Filter Context Box

I guess that's where I'm lost. It seems the Bubble Plot is dependent on all of the source ones. You can in effect place your "final" plot in a data filter source box itself, but then you will see all of the undesired data, just unselected/grayed out.

txnelson
Super User

Re: Nested/Multiple Data Filter Context Box

I have been playing with the code, but I haven't been able to get it to work the way you have specified.  

Sorry, maybe another community member has an idea.

Here is an example where there are 2 independent paths taken from a single selection graph.....I think this is close to what you want

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Potential",
	Character,
	"Nominal",
	Set Values(
		{"1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2",
		"1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2"}
	)
);

New Window( "Shared Local Filter",
	Data Filter Context Box(
		H List Box(
			Data Filter Source Box(
				H List Box(
					Graph Builder(
						Size( 208, 207 ),
						Show Control Panel( 0 ),
						Show Legend( 0 ),
						Variables( X( :age ) ),
						Elements( Bar( X, Legend( 3 ) ) ),
						SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Filter" )} ) )
					), 
					 
					//Data Filter Context Box(
					V List Box(
						Data Filter Source Box(
							H List Box(
								Graph Builder(
									Size( 208, 207 ),
									Show Control Panel( 0 ),
									Show Legend( 0 ),
									Variables( X( :Potential ) ),
									Elements( Bar( X, Legend( 3 ) ) ),
									SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Filter" )} ) )
								),
								Platform(
									Current Data Table(),
									Bubble Plot( Y( :weight ), X( :height ), Sizes( :age ), Title Position( 0, 0 ) )
						
								)
							), 

						),
						Data Filter Source Box(
							H List Box(
								Graph Builder(
									Size( 208, 207 ),
									Show Control Panel( 0 ),
									Show Legend( 0 ),
									Variables( X( :sex ) ),
									Elements( Bar( X, Legend( 3 ) ) ),
									SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Filter" )} ) )
								), 

								Platform(
									Current Data Table(),
									Bubble Plot( X( :weight ), Y( :height ), Sizes( :age ), Title Position( 0, 0 ) )
								)
							)
						)
					)
					//)
				)
			)
		)
	)
);
Jim
ausername
Level II

Re: Nested/Multiple Data Filter Context Box

Thanks Jim! I had come up with something similar. I was trying to find a way to hide/downsize the unselected points but it doesn't look like that's a possibility.

I think I have also arrived at a different way of doing this altogether: by using the "by()" and looping through each ToolID using a separate SendToGroup(). It's a bit more complicated to set up the titles then, but I will post the results once I have it figured out. Hopefully it helps someone in the future as all your posts have done!

Re: Nested/Multiple Data Filter Context Box

I've attached two examples of similar layouts to what you describe:

 

SFCrimeNestedFilter.jsl demonstrates how to nest the Data Filter Context Box to get a cascading / hierarchical behavior in the filters.  This approach works in JMP 10+, though the syntax that I use for the Tab Box is JMP 13+.

 

SFCrimeFilterWithWhere.jsl replaces the inner filter with a Where() clause for each report.  This type of layout works in JMP 14 but did not work in prior releases.  The issue is that the filter is using the full table, while the report is using a subset table.

 

I hope this helps!