Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic sub-queries in a time range?
ManInBlack
Hi altogether,
i have got such big problem:
My report should have count queries about a special time range. By using a parameter the user can input the start date and end date. A field (products) has to be counted, but the aggregation should be monthly:
for example:
Start Parameter: 01.04.2009
End Parameter: 09.08.2009
The report should show following result:
__________________________________________________________________________________________
04.2009_ _ _ _| _ _ _ _05.2009_ _ _ |_ _ _ _ _06.2009_ _ _| _ _ _ _ _07.2009_ _ _ |_ _ _ _ _08.2009 _ _|
_ _ 20_ _ _ _ _| _ _ _ _ _ 25_ _ _ _ | _ _ _ _ _ 23_ _ _ _ _| _ _ _ _ _ 18_ _ _ _ _ _| _ _ _ _ _ _14 _ _ _ |
_____________|__________________|__________________|____________________|_________________
(The query is a sql-query which counts the products of a month:
select count of ProductA where time > 01.04.2009 and time < 31.04.2009)
The goal is to let the querries dynamical. If the time range (start parameter and end parameter) will be changed, more or less sub-queries have to be done.
I don´t want to select fix dates within of the where-clause.
The dynamic and variable factor is really important. Because an user would like to call queries only for 2 month, the other user for 2 years.
Is it possible to accomplish that, if yes, about which way? And how is the design of the report?
Please experts help me, if you have an idea. At the moment i am helpless and have no plan.
If my explanations aren´t exact enough please could you give me a post.
Maybe thank you very much in advance.
Byebye
ManInBlack
Find more posts tagged with
Comments
ManInBlack
I could solute it, but only with fix date parameters.
For each count result, i have a count query (and therefore data sets) with the date parameters.
The relation of a query to a data set is in my case 1:1.
For example:
- Data Set1:
select count productA where date >= 01.04.2009 and date < 01.05.2009
- Data Set2:
select count productA where date >= 01.05.2009 and date < 01.06.2009
- Data Set3:
// i use date parameters
select count productA where date >= params["3rdDate"] and date < params["4thDate"]
- further more Data Sets
All in all i have 5 queries with nearly the same functionality. The only difference are the dates. In my eyes it isn´t efficient.
I also have more products (productA, productB, productC,...). For every product i also have to create 5 data sets with the dates.
3 products --> are 15 data sets / queries
Hopefully i could give you an understanding of my huge problem.
Are there any possiblities to construct it more comfortable?
thx
mwilliams
Hi ManInBlack,
What does your data look like in your dataSet? This looks like something that could be done in a crosstab.
ManInBlack
Hi Michael,
thank you for your answer.
At the moment I have 5 Data Sets:
Every Data Set consits of 1 value, the count of products of every month.
This fact is really uncomfortable.
Michael, in which way you would like to realize that task:
- count query of products / of every month (January - July)
- the query should cover 3 Products
In order to calculate that, we need 6 queries because of the months, and that multiplicated with the products:
6 Month x 3 Products = 18 Queries
To implement it, I need in BIRT 18 Data Sets, or are for this task other solutions?
Like Sub-queries,etc.
BIRT is really a great tool, but as far as i know, that condition is fact:
1 query = 1 data set
Best Regards
p.s.
I should write an roman, because my questions and notes are so long
mwilliams
ManInBlack,
If you can just show me a data setup how you would like to have your dataSet(s) look, I'll test on that data to see if I can get your desired output. Does your data all come from one table and you're just running multiple queries out of it for each individual month? I'm just trying to get an idea of your database setup and how we can optimize the setup of your report to show what you're wanting.
ManInBlack
Hi Michael,
thank you for your help.
I will create a simple birt example and post it here. Therefore the struktur of the database and the multiple querries are viewable.
See you later, best regards.
ManInBlack
ManInBlack
Hi Michael,<br />
<br />
sorry for my late answer.<br />
<br />
Under the link you can find a rptdesign file:<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/examples/solution/StaticCrosstab.rptdesign'>http://www.eclipse.org/birt/phoenix/examples/solution/StaticCrosstab.rptdesign</a><br
/>
<br />
In the Data Set AllOrders,<br />
I would like to allocate the data field "Orders::CUSTOMERNUMBER" of every month, within of a time-range. The time-range (begin - end date) should be entered by using a parameter through the user.<br />
<br />
For example:<br />
<br />
The user enter the beginn Date: 2003-02-02 <br />
and the end-date: 2003-03-27<br />
<br />
Now the count of all orders<br />
- of the February<br />
- and of March<br />
should be showed.<br />
<br />
If the user changes the time range, than the count field will change.<br />
<br />
It would be a pleasure if you could help me.<br />
<br />
Thank you<br />
<br />
Byebye<br />
ManInBlack