BookmarkSubscribeSubscribe to RSS Feed

Working with multiple queries simultaneously

Highlighted
aserino

Occasional Contributor

Joined:

Jan 31, 2018

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

Occasional Contributor

Joined:

Jan 31, 2018

Solution

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.

3 REPLIES
gzmorgan0

Community Trekker

Joined:

Jul 25, 2016

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

Occasional Contributor

Joined:

Jan 31, 2018

Solution

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

Community Trekker

Joined:

Jul 25, 2016

Congratulations!