cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMPĀ® Marketplace
Choose Language Hide Translation Bar
TomF
Level III

How do I make one Data Filter mirror another?

I have a window containing two graph builders, pulling from two different datasets, and I want to filter both graphs with a single Data Filter. I don't think this is possible. I've thought about instead using two "synced" data filters, but couldn't figure it out. Last week at JMP Discovery, @danschikore pointed me toward event handlers as a possible solution for using two synced filters. I think I'm close to getting it to work, but I'm stuck.

The script below creates the two filters and two graphs. I want the selections made in the top filter to be automatically reflected in the bottom filter. Once that works, I will hide the bottom filter and the user will see one filter controlling both graphs.

As it is now, when the user makes a selection in the top filter, the script prints that Where clause to the log using "Get Where Clause", but I need to apply this where clause to the bottom filter. I want a command like "Set Where Clause" that would let me shove that where clause text into the bottom filter, but it doesn't seem to exist.  I'm really hoping to avoid the scenario where I have to "unpack" the text string (below) and turn it into a form I can pass to the lower filter.
Select Where( :name == \!"ALICE\!" | :name == \!"BARBARA\!" )

Just to convince myself I can get the first filter to control the second one in some fashion, I have the first filter clearing the second filter's selection. That means I can talk to both filters; I can extract the where clause from the first; I just can't apply it to the second.

As a bonus question: Once this syncing works. I want to hide the second filter.  The last line of the script hides the first filter. Does anyone know how I could modify this to hide the second filter instead?

Thanks,

Tom

TomF_0-1730390491239.png

 

15 REPLIES 15
TomF
Level III

Re: How do I make one Data Filter mirror another?

I did mean concatenate. By doing update/join you are associating the height data, which has no year associated with it, with the weight data, which is yearly. The new graph makes it look like Barbara's height was measured to be 60 inches in 2022, 23, and 24, which it was not.
The trick here  is that the data in the bottom is associated with year, but the data in the top is not, and I want one centered bar for it.  Maybe instead of height I should have used "GDP per capita when and where the student was born" -- clearly not associated with 22/23/24.
Because the underlying data for the top and bottom graphs have a different structure, I think I need two separate graph builders to create the picture I want (above).

hogi
Level XII

Re: How do I make one Data Filter mirror another?

Agree : )

 

For Big Class there might be some easy solution, but this solution might not help with the actual issue.

TomF
Level III

Re: How do I make one Data Filter mirror another?

@hogi  I don't completely understand what your code does, but I put it in and it worked perfectly. Thank you!

To be honest, I did not really escape the trap door. I fell in and then pulled myself back out. I was following this community post, but I saw no reason to store the event handler as a variable, so I didn't. It didn't work, I followed the post more carefully, storing it as a variable, it started working, and I carried on without understanding what happened. I put comments in my code with your two trapdoors, hoping to save someone the bruises in the future.

In this case, my filtering is simple -- always one column -- and both my tables contain the same x values, so no concerns there.

I've posted the updated code above.

hogi
Level XII

Re: How do I make one Data Filter mirror another?

Hi @TomF , I added some comments to the code to explain the individual steps.

 

One trick is the Extract Expr() - it scans the expression and searches for a specific pattern.

I just had a look at an old script where I used one data filter to control 4 additional data filters in the same Dashboard.
And it looked like

		For( i = 1, i <= N Arg( filterScript ), i++,
			If( Head( Arg( filterScript, i ) ) == Expr( Add Filter() ),
				filterExpression = Arg( filterScript, i )
			)
		);

The approach via Extract Expr() is much more elegant - I just learned it last year from @jthi in this discussion:
šŸ™ Expression Indexing: read and write access 

 

The other trick:  Eval (Eval Expr(  Expr())) - a Swiss army knife!
It will solve 95% of your issues in JSL
Expression Handling in JMP: Tipps and Trapdoors 

TomF
Level III

Re: How do I make one Data Filter mirror another?

@hogi, thanks for these links. Eval/Eval Expr() has been the most frustrating part of JSL for me over the past few years. I've used it successfully a few times by copying and tweaking examples from the Community, but never felt like I actually grasped it well.  I look forward to going through the list of resources you've collected and maybe that will help it finally sink in. I know it's something I need to add to my toolkit.

hogi
Level XII

Re: How do I make one Data Filter mirror another?

Eval(): run the code  *)

Eval Expr: pre-evaluate everything wrapped with Expr() *)

Expr(): marker for code which has to get pre-evaluated  *)

 

*) my brain : "the E word" - 3 times.

and the 4th one is Expr Name()    ; -)