Where Clause in graph loopI have some code that is designed to build a report based on some filtering. It will be fed two lists, the first will determine which materials get pulled (in this example that will be Gender_List), the second determining which properties get graphed (In this example that will be Property_List). The idea being that there will be a loop through each Gender that will create a matrix of graphs for all selected properties. There is also an over-arching, unfiltered graph at the top of the report
There are two ways to do this.
The first with intrinsic where clauses in the graphs. I've mostly gotten this to work, except that the Where clause ends up taking up a position in the line up box. Also for some reason in the mockup I have below I have a bug that I don't entirely understand (my full version does not have that bug, but would still be curious if someone knows how to fix it). Here is the mockup code
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Gender_List = {"M","F"};
age_list = {12,13,14,15};
Property_List = {"Age", "Height", "Weight"};
w= new window("test",
VLB = V List Box ("A",
dt<<DISTRIBUTION></DISTRIBUTION>
The second is with data filter context boxes that wrap each iteration of the loop of graphs. That one I haven't been able to get to work. If I can get the where version above to work I don't think I'll need to worry too much about the data filter context box/wrap.
Anyways, any thoughts on how to clean up the code above to remove those Where clauses from the line up box?
ScriptingRe: Where Clause in graph loopI reworked your script a bit. You had some recursive Appends in your code that were not working. See if this gets you what you want
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Gender_List = {"M", "F"};
age_list = {12, 13, 14, 15};
Property_List = {"Age", "Height", "Weight"};
w = New Window( "test", VLB = V List Box( Text Box( "A" ), dt << Distribution( Nominal Distribution( Column( :age ) ) ) ) );
For( j = 1, j <= N Items( Gender_List ), j++,
VLB << Append( Text Box( Gender_List[j] ) );
VLB << Append(
LB = LB = Lineup Box( N Col( 2 ), spacing( 10 ),
For( i = 1, i <= N Items( Property_List ), i++,
gb = dt << Distribution( Continuous Distribution( Column( Property_List[i] ) ), where( :Sex == Gender_List[j] ) )
)
)
);
);Re: Where Clause in graph loopDefinitely a major improvement, but it looks like I still have that hanging "where( :Sex == Gender_List[j]" clause showing up in the lineup box. Any idea how to kill that?Re: Where Clause in graph loopYou can remove them for example with this in the end of script:
whereTb = w << XPath("//TextBox[contains(text(), 'Where(:sex == Gender_List[j])')]");
whereTb << Delete;But in this case I would guess it won't help because Lineup seems those Where textboxes as elements and the window gets messed up before you delete them.
Re: Where Clause in graph loopHow about this:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Gender_List = {"M", "F"};
age_list = {12, 13, 14, 15};
Property_List = {"Age", "Height", "Weight"};
w = New Window( "test", VLB = V List Box( Text Box( "A" ), dt << Distribution( Nominal Distribution( Column( :age ) ) ) ) );
For( j = 1, j <= N Items( Gender_List ), j++,
VLB << Append( Text Box( Gender_List[j] ) );
VLB << Append(
LB = Lineup Box( N Col( 2 ), spacing( 10 ),
For( i = 1, i <= N Items( Property_List ), i++,
eval(substitute(
expr(dt << Distribution( Continuous Distribution( Column( _col_ ) ), where( :Sex == _select_) )),
expr(_col_),Property_List[i],
expr(_select_), Gender_List[j]
))
);
);
);
);Re: Where Clause in graph loopStill can't seem to figure out how to get rid of that "where" clause in the lineup box. I switched it over to a graph builder object to see if header/footer preferences would remove it, but didn't seem to do it.
I've tried to re-write this a data filter wrapping the LB. That has some advantages anyways as it allows some customization by the user. This seems to work, however, as you can see it looks a little wonky because the Data Filter is incredibly collapsed.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Gender_List = {"M", "F"};
age_list = {12, 13, 14, 15};
Property_List = {"Age", "Height", "Weight"};
w = New Window( "test", VLB = V List Box( Text Box( "A" ),
dt << Graph Builder(Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ) ),
Elements( Histogram( X, Legend( 6 ) ) )
)
)
);
For( j = 1, j <= N Items( Gender_List ), j++,
VLB << Append( Text Box( Gender_List[j] ) );
VLB << Append(
data filter context box(
LB = LB = Lineup Box( N Col( 2 ), spacing( 10 ),
For( i = 1, i <= N Items( Property_List ), i++,
gb = dt << Graph Builder(
Size( 534, 450 ),
Show Control Panel(0 ),
Variables( X(Column( Property_List[i] ) )),
Elements( Histogram( X, Legend( 6 ) ) ),
/*Where( :Sex == Gender_List[j] ) ),*/
),
)
),
dt<<DATA filter=""></DATA>
I tried loading the data filter at the top of the LB but that did not seem to work.
Any thoughts on how to clean this up? This technically works but looks a little junky.
Re: Where Clause in graph loopIf you add @jthi code to the code I provided, it will give you what you want

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Gender_List = {"M", "F"};
age_list = {12, 13, 14, 15};
Property_List = {"Age", "Height", "Weight"};
w = New Window( "test", VLB = V List Box( Text Box( "A" ), dt << Distribution( Nominal Distribution( Column( :age ) ) ) ) );
For( j = 1, j <= N Items( Gender_List ), j++,
VLB << Append( Text Box( Gender_List[j] ) );
VLB << Append(
LB = LB = Lineup Box( N Col( 2 ), spacing( 10 ),
For( i = 1, i <= N Items( Property_List ), i++,
gb = dt << Distribution( Continuous Distribution( Column( Property_List[i] ) ), where( :Sex == Gender_List[j] ) )
)
)
);
);
whereTb = w << XPath("//TextBox[contains(text(), 'Where(:sex == Gender_List[j])')]");
whereTb << Delete;