cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
aserino
Level III

Working with multiple queries simultaneously

Hello,

 

I'm attempting to work with two pre-built query builder queries simultaneously. I'd like to eventually be able to plot the data from one ontop of the other using graph builder, however the code below is throwing an access or evaluation error on dtGroup and dtTarget.

Group = Open("C:\Temp\Group$.jmpquery", Private );
Target = Open("C:\Temp\Target$.jmpquery", Private );

Group << Run Background(
	On Run Complete(
		dtGroup = queryResult;
	)
);
Target << Run Background(
	On Run Complete(
		dtTarget = queryResult;
	)
);

dtGroup << New Column( "ExGroup",
	Numeric,
	"Ordinal", 
	Formula( :Data )
);

dtTarget << New Column( "ExTarget",
	Numeric,
	"Ordinal", 
	Formula( :Data )
);

I've tried making the variables global  (global:dtGroup = queryResult;) but the same error occurs. Any idea how to use both? Is it a scope/namespace issue?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
aserino
Level III

Re: Working with multiple queries simultaneously

This would work, however, I'm unsure how to then perform functions using the data from both queries. Also, queryResult is built into the query  On Run Complete() function.

 

After some troubleshooting and getting some expert advice, the problem has to do with the queries not finishing before the script moves onto the next command. To solve this, I would need to change the Run Background() to Run Foreground().  I've tested it out now and it works great.

View solution in original post

3 REPLIES 3
gzmorgan0
Super User (Alumni)

Re: Working with multiple queries simultaneously

I cannot see where you have defined query result.  Try the syntax in the attached script.

 

Group = Open("C:\Temp\Group$.jmpquery", Private );
Target = Open("C:\Temp\Target$.jmpquery", Private );

dtGroup = Group << Run Background(
	On Run Complete(
	  New Column( "ExGroup",
	    Numeric,
	    "Ordinal", 
	    Formula( :Data ) // this assumes there is a column name :Data in your query
         );
    )
);

dtTarget = Target << Run Background(
	On Run Complete(
          New Column( "ExTarget",
	    Numeric,
	    "Ordinal", 
	    Formula( :Data ) // this assumes there is a column name :Data in your query
         );	
    )
);

Here is a similar example, created and tested for JMP sample data Big Class.jmp. 

Test = Open("C:\Temp\test.jmpquery",private);

dtTest = Test << Run Background(
	OnRunComplete(
	  New Column( "ExTest",
	    Numeric,
	    "Ordinal", 
	    Formula( :age ) // this assumes there is a column name :Data in your query
      );
    )
);

 

aserino
Level III

Re: Working with multiple queries simultaneously

This would work, however, I'm unsure how to then perform functions using the data from both queries. Also, queryResult is built into the query  On Run Complete() function.

 

After some troubleshooting and getting some expert advice, the problem has to do with the queries not finishing before the script moves onto the next command. To solve this, I would need to change the Run Background() to Run Foreground().  I've tested it out now and it works great.

gzmorgan0
Super User (Alumni)

Re: Working with multiple queries simultaneously

Congratulations!