Jump to content
We've recently updated our Privacy Statement, available here ×

combining two queries from two different data sources


mbannout_1

Recommended Posts

Hello guys, i'm not an expert in jasper reports but i need to make a complex report. i am using Jasperserver community edition and ireport 5.6.

i need to run 2 queries:
query 1 on datasource 1, result will be 4 fields as follows: MID, Last order, Total Sales, Total purchases.
query 2 on datasource 2, result will be 5 fields as follows: MID, Shop Code, Region, Branch, SM ID.

what i need the report to do is display the results in one table like this: MID, Shop Code, Region, Branch, SM ID, Last order, Total Sales, Total purchases.
then i need to show a little summary table that shows different counters example: number of entries with total sales below $500 per region etc.

what is the best and simplest way to go about ? any help is appreciated.

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Don't know of a decent way to use multiple data sources in the same report unit without a subreport for each distinct datasoure, but if you put that in place and return values from the subreports, then combine those in your main report you'll get what you need accomplished. See my approach here:

 

http://community.jaspersoft.com/questions/540250/clarification-multiple-datasources-report

Link to comment
Share on other sites

Thanks for the reply "gertbeedfrobe"

I have tried what you suggested and it works to some extent. the subreport is supposed to take one input from main report called MID for each record and return 4 variables. the problem is that for each page only the first record is correct, the remaining records are repeats for the first one.

please see below the results i am getting:

MID        Last Order     Purchases    Sales        Shop Code        Region    Branch     SMID
10025   06-Mar-17      500                 730           DDCAT01133     Central     Riyadh     1101101
10061   06-Mar-17      1300               1170         DDCAT01133     Central     Riyadh     1101101
10070   02-Mar-17      1100               1070         DDCAT01133     Central     Riyadh     1101101
10075   08-Mar-17      500                 730            DDCAT01133     Central     Riyadh     1101101
 
first 4 columns are from the main report, second 4 columns are returned values from the subreport. as you can see, the returned values are repeating and only update on the second page.
what could be wrong ?
 

 

 

 


 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...