Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Designing Reports Based on Single Data Model
xplorerdev
<p>Hi All,</p>
<p> </p>
<p>I am converting a set of 70+ reports, already developed in other BI tools, into BIRT 4.4.2.</p>
<p> </p>
<p>I have attached a screenshot of my data model. The data model has close to 60 dimension tables, 10 snowflake tables and 1 fact table. (<em>Screenshot has fewer components as it just gives a picture of how the model looks like</em>)</p>
<p> </p>
<p>I have tried creating a sample report with 4 measures and 8 dimensions and it works fine. The reports comes within 5 secs. But now, I am unable to expand it. (<em>Report design attached</em>)</p>
<p> </p>
<p><strong>I need to now add the remaining dimensions.</strong> All these dimension will be available to the user as parameter inputs. I have tried creating separate datasets, tried writing custom sql query, tried creating joint data sets etc., but all effort goes for a toss as the report is not running at all.</p>
<p> </p>
<p>Any thoughts/ideas aound the designing part will be highly appreciated.</p>
<p> </p>
<p>Best Regards</p>
Find more posts tagged with
Comments
micajblock
<p>Is this OS BIRT or commercial BIRT?</p>
xplorerdev
<p>I intend to use Open Source BIRT.</p>
micajblock
<p>If all 60 dimensions are possible inputs, I would recommend to dynamically build the query based on parameters. Since I know about your other posts, you might need to dynamically build the cubes and measures.</p>
xplorerdev
<p>Thanks for the reply Mica.</p>
<p> </p>
<p>I created multiple datasets: 1 for FACTquery, 3 for snowflake tables and 29 for dimension tables.</p>
<p> </p>
<p>Then I created a joined dataset, MASTER, in which I joined all the above datasets. Then I have created a cube_MASTER with 2 Groups for the Dynamic Time Period and Dimension and thats it.</p>
<p> </p>
<p>Well, initially, the reports were coming fine, but after the second snowflake was added to MASTER, due to the huge data size (<em>i.e. 10+ lacs records in FACT</em>), the MASTER just won't execute.</p>
<p> </p>
<p>The FACT dataset query took 30 secs to preview. But the MASTER takes 9+ minutes for 5 lac records and more than 15 mins if, in FACT dataset, I am Selecting All Rows from Datasource.</p>
<p> </p>
<p>I am trying to improve on the query. I just wanted to share my design so that you could, IN YOUR FREE TIME
, take a look and see if its the right way to approach or I need to rethink.</p>
<p> </p>
<p>Best Regards</p>
micajblock
<p>You are taking a wrong approach. OS BIRT does not have a semantic layer (commercial BIRT does, but you want a free product).</p>
<p> </p>
<p>I always discourage joined data sets if both data sets are from the same database as the join is done in Java. BIRT will almost never perform as well as the source database.</p>
<p> </p>
<p>Every report should have ONLY the data it needs. See my previous note in this thread. The idea would be to dynamically build the query based on user inputs. One query.</p>
xplorerdev
<p><span style="font-size:14px;">Hi Mica,</span></p>
<p> </p>
<div><span style="font-size:14px;">Made modification to the report (<em><strong>attached</strong></em>). Kept one dataset, FACT, with a small query. </span>Now, to make the query dynamic (i.e. <em>give different result based on user inputs</em>), we need to add some code in the <strong>beforeOpen </strong>window for the FACT dataset and I think it should be something like the following:</div>
<div> </div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">SELECT </span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">PERIOD, </span><span style="color:#008000;">-- Computed column for Crosstab Row.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">DIMENSION, </span><span style="color:#008000;">-- Computed column for Crosstab Column.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">SUM(FACT.ACCN_IN_FORC) AS "NO OF ACCOUNTS" </span><span style="color:rgb(0,128,0);">-- Single measure.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">FROM FACT </span><span style="color:#008000;">-- Fact table.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">LEFT OUTER JOIN TIME ON (FACT.MIS_DAT_FK = TIME.DAY_PK) </span><span style="color:#008000;">--Time dimension table</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">LEFT JOIN DIM ON (FACT.NATN_FK = DIM.NATN_PK) </span><span style="color:#008000;">--Other dimension table</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">WHERE PERIOD = params["pPeriod"].value </span><span style="color:#008000;">--Crosstab Row value = <strong>pPeriod </strong>paramater user input value.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">AND DIMENSION = params["pDimension"].value </span><span style="color:#008000;">--Crosstab Column value = <strong>pDimension </strong>paramater user input value.</span></span></div>
<div><span style="font-size:14px;"><span style="color:#0000cd;">GROUP BY PERIOD, DIMENSION</span></span></div>
<div> </div>
<div>Performed few steps but, not able to put together a working solution.
</div>
<div> </div>
<div><span style="font-size:14px;">Best Regards</span></div>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145907" data-time="1478784314">
<div>
<p>You are taking a wrong approach. OS BIRT does not have a semantic layer (commercial BIRT does, but you want a free product).</p>
<p> </p>
<p>I always discourage joined data sets if both data sets are from the same database as the join is done in Java. BIRT will almost never perform as well as the source database.</p>
<p> </p>
<p>Every report should have ONLY the data it needs. See my previous note in this thread. The idea would be to dynamically build the query based on user inputs. One query.</p>
</div>
</blockquote>
<p> </p>
<p>Hi Mica,</p>
<p> </p>
<p>I have been able to put something together. Report design attached. Main thing to see in the design would be the <strong>beforeOpen</strong> script. The report seems to be running fine and timings are also good.</p>
<p> </p>
<p>Is this the correct approach?</p>
<p> </p>
<p>Best Regards</p>
micajblock
<p>You are going in the right direction, but I would change the from clause as well. I should be able to build an example using Classic Models today.</p>
<p>P.S. I like your use of the Case statement for the calculation of the No. Accounts, that is what I was planning on recommending to you. </p>
micajblock
<p>See attached example. All the code is in the beforeOpen event.</p>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145932" data-time="1479125253">
<div>
<p>You are going in the right direction, but I would change the from clause as well. I should be able to build an example using Classic Models today.</p>
<p>P.S. I like your use of the Case statement for the calculation of the No. Accounts, that is what I was planning on recommending to you. </p>
</div>
</blockquote>
<p> </p>
<p>Ahh. Finally. Thanks.
</p>
<p> </p>
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145941" data-time="1479159673">
<div>
<p>See attached example. All the code is in the beforeOpen event.</p>
</div>
</blockquote>
<p> </p>
<p>This new code seems simpler. Thanks. <span style="color:#008000;">Its working for Year/Quarter/Month.</span> But it does not seem to work when I am adding a second DIMENSION.</p>
<p> </p>
<p>My 1st default dimension is <em>Nationality</em>. I am taking <em>Status Code</em> as my second dimension and have altered the <strong>beforeOpen </strong>script in the foll manner:</p>
<p> </p>
<div><em>if (params["pDimension"].value == "Status Code") {</em></div>
<div><span style="color:#008000;"><em>//for the select portion</em></span></div>
<div><em>this.queryText=this.queryText.replace("D2.NATN","D3.STAT_COD");</em></div>
<div><span style="color:#008000;"><em>//for the group by portion</em></span></div>
<div><em>this.queryText=this.queryText.replace("D2.NATN","D3.STAT_COD");</em></div>
<div><span style="color:#008000;"><em>// replace the from clause</em></span></div>
<div><em>this.queryText=this.queryText.replace("LEFT JOIN ARAWSH_MRT.T_DIM_NATN_CC D2 ON F1.NATN_FK=D2.NATN_PK","LEFT JOIN ARAWSH_MRT.T_DIM_STC_ACCN_STAT_CC D3 ON F1.STAT_COD_FK=D3.STAT_COD_PK");</em></div>
<div><em>}</em></div>
<p> </p>
<p>When I select <em>Status Code</em> from pDimension dropdown, I get the following error:</p>
<p> </p>
<div><span style="color:#ff0000;">org.eclipse.birt.report.data.oda.jdbc.JDBCException: SQL statement does not return a ResultSet object.</span></div>
<div><span style="color:#ff0000;">SQL error #1:[ActuateDD][SQLServer JDBC Driver][SQLServer]The multi-part identifier "D3.STAT_COD_PK" could not be bound.</span></div>
<div><span style="color:#ff0000;">SQL error #2:[ActuateDD][SQLServer JDBC Driver][SQLServer]The multi-part identifier "D3.STAT_COD" could not be bound.</span></div>
<div><span style="color:rgb(255,0,0);">SQL error #3:[ActuateDD][SQLServer JDBC Driver][SQLServer]Statement(s) could not be prepared.</span></div>
<p> </p>
<p>Seems to be some problem with the join but I think I have named it in the right manner. The sql query works fine on the database though. :huh:</p>
<p> </p>
<p><em><strong>Report design attached.</strong></em></p>
<p> </p>
<p>Best Regards</p>
micajblock
<p>that is because you have spaces in your original query before an after the equal sign. What you have in your script is this:</p>
<pre class="_prettyXprint">
this.queryText=this.queryText.replace("LEFT JOIN ARAWSH_MRT.T_DIM_NATN_CC D2 ON F1.NATN_FK=D2.NATN_PK","LEFT JOIN ARAWSH_MRT.T_DIM_STC_ACCN_STAT_CC D3 ON F1.STAT_COD_FK=D3.STAT_COD_PK");</pre>
<p>What you need is this:</p>
<div>
<pre class="_prettyXprint">
this.queryText=this.queryText.replace("LEFT JOIN ARAWSH_MRT.T_DIM_NATN_CC D2 ON F1.NATN_FK = D2.NATN_PK","LEFT JOIN ARAWSH_MRT.T_DIM_STC_ACCN_STAT_CC D3 ON F1.STAT_COD_FK=D3.STAT_COD_PK");</pre>
</div>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145956" data-time="1479225186">
<div>
<p> </p>
<p>that is because you have spaces in your original query before an after the equal sign. What you have in your script is this:</p>
<pre class="_prettyXprint">
this.queryText=this.queryText.replace("LEFT JOIN ARAWSH_MRT.T_DIM_NATN_CC D2 ON F1.NATN_FK=D2.NATN_PK","LEFT JOIN ARAWSH_MRT.T_DIM_STC_ACCN_STAT_CC D3 ON F1.STAT_COD_FK=D3.STAT_COD_PK");</pre>
<p>What you need is this:</p>
<div>
<pre class="_prettyXprint">
this.queryText=this.queryText.replace("LEFT JOIN ARAWSH_MRT.T_DIM_NATN_CC D2 ON F1.NATN_FK = D2.NATN_PK","LEFT JOIN ARAWSH_MRT.T_DIM_STC_ACCN_STAT_CC D3 ON F1.STAT_COD_FK=D3.STAT_COD_PK");</pre>
</div>
<p> </p>
</div>
</blockquote>
<p> </p>
<p>I did what you suggested but still the same '<span style="color:rgb(255,0,0);font-family:'Source Sans Pro', sans-serif;">The multi-part identifier</span>' error.</p>
<p> </p>
<p>I also checked in your report design script: If I put space before & after the = sign for Country, I am getting the foll error:</p>
<div><span style="color:#ff8c00;"><em>SQL error #1:Column 'C.COUNTRY' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'C.COUNTRY' is not a column in the target table.;</em></span></div>
<p> </p>
<p>It seems, there is some other join issue in my report script, which is not happening when I run the query in the database but is there via the script.</p>
xplorerdev
<p>huh!</p>
<p> </p>
<p>My brain is 100% fried now. Absolutely no clue about this <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">'</span><span style="font-family:'Source Sans Pro', sans-serif;color:rgb(255,0,0);">The multi-part identifier</span><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">' error. I have tried with diff dimensions. I have used tables from <strong>.dbo</strong> schema. I have checked all combinations of adding/removing a space. I have checked table-names/column-names/alias etc, all seems to be fine. I created another report using </span><span style="color:#008000;"><span style="font-family:'Source Sans Pro', sans-serif;"><strong>Classicmodels and that works fine</strong></span></span><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">. <u>But my report will not work</u>. As soon as I add a second dimension, I get the same error:</span></p>
<p> </p>
<p><span style="color:#ff0000;"><em><strong>Caused by: java.sql.SQLException: [ActuateDD][SQLServer JDBC Driver][SQLServer]The multi-part identifier "s.stat_cod_pk" could not be bound.</strong></em></span></p>
<p> </p>
<p>New report design attached.</p>
<p> </p>
<p>Best Regards</p>
micajblock
<p>Are all the dimensions of the same data type?</p>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145979" data-time="1479309813" data-date="Today, 08:53 PM"><p>Are all the dimensions of the same data type?</p></blockquote>
<br>
Yes. Datatypes follow a similar definition. STAT_COD_PK and NATN_PK are Integer. STAT_COD and NATN are Varchars.<br><br>
Best Regards.
micajblock
<p>so they are not on the same data type.Integer and varchar are not the same.</p>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145981" data-time="1479312112" data-date="Today, 09:31 PM"><p>so they are not on the same data type.Integer and varchar are not the same.</p></blockquote><br>
Yes. The joining keys are Integer and the name/description is varchar.
micajblock
<p>can you attach a text file with the different queries? Also what are the data types of each fields.</p>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145984" data-time="1479315244" data-date="Today, 10:24 PM"><p>can you attach a text file with the different queries? Also what are the data types of each fields.</p></blockquote><br>
Sure. I just reached home. Will send queries tomm mrng.
micajblock
<p>Please verify that the queries you send work before you attach them, thanks.</p>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="145986" data-time="1479317929">
<div>
<p>Please verify that the queries you send work before you attach them, thanks.</p>
</div>
</blockquote>
<p> </p>
<p>Thanks for the support Mica. I have attached a sample report design, <em><strong>Dynamic Crosstab_wip_3.rptdesign</strong></em>. Queries, datatypes and other design details are in the attached text file, <em><strong>Multipart Identifier error investigation.txt</strong></em>.</p>
<p> </p>
<div>Error on selecting Status Code from dropdown:</div>
<div><span style="color:#ff0000;"><em>java.sql.SQLException: [ActuateDD][SQLServer JDBC Driver][SQLServer]The multi-part identifier "s.stat_cod_pk" could not be bound.</em></span></div>
<div> </div>
<div>Error on selecting Nationality from dropdown:</div>
<div><span style="color:#ff0000;"><em>java.sql.SQLException: [ActuateDD][SQLServer JDBC Driver][SQLServer]The multi-part identifier "n.natn_pk" could not be bound.</em></span></div>
<p> </p>
<p>Best Regards</p>
micajblock
<p>No idea, as everything looks good. As I cannot run your report I am somewhat limited. Here is what I would do.</p>
<ol><li>Copy your report.</li>
<li>Copy your code form the beforeOpen script</li>
<li>Delete the cube and the data set.</li>
<li>Add a label with the text being your initial query</li>
<li>In the onCreate script of the label paste the code from the beforeOpen</li>
<li>replace all this.queryText to this.text</li>
<li>run the report with the different parameters and then see what is wrong with the queries.</li>
</ol>
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="146010" data-time="1479425966" data-date="Today, 05:09 AM"><p>No idea, as everything looks good. As I cannot run your report I am somewhat limited. Here is what I would do.<br></p><ul class="bbcol decimal"><li>Copy your report.</li><li>Copy your code form the beforeOpen script</li><li>Delete the cube and the data set.</li><li>Add a label with the text being your initial query</li><li>In the onCreate script of the label paste the code from the beforeOpen</li><li>replace all this.queryText to this.text</li><li>run the report with the different parameters and then see what is wrong with the queries.</li></ul></blockquote> <br><br>
Seems like a lot of work. I am thinking what I could possibly do to debug this further. Hmmmm.
micajblock
<p>Not a lot at all. I did it in 5 minutes (attached). Basically what I found out is it appears there some hidden characters or something. I copied the string directly from the original query and it works.</p>
xplorerdev
Ohh. Great. I just stepped into office. Will try out the attached and give a report later. I guess its too late for you now. Good night and thanks.:)
xplorerdev
<p>Finally..its working !</p>
<p> </p>
<p><u>Here is what I thought and what I did:</u> <em>Multipart Identifier</em> error was suggesting that the dimension in the select clause was not able to reference the table/alias. It seemed to me that the <strong>beforeOpen </strong>script was executing sequentially. Thus I needed to define the table/alias first so that the select clause dimension could point to it. So, I put the <strong>From </strong>clause <span style="color:rgb(0,0,205);"><em>this.queryText.replace</em></span> at the top, followed by the <strong>Select </strong>clause and finally the <strong>Group By</strong> clause.<span style="color:rgb(0,128,0);"><strong>It works now</strong></span>.
</p>
<p> </p>
<p><span style="color:#ff0000;">What I had all this while, which was not working:</span></p>
<pre class="_prettyXprint _lang-auto _linenums:0">
if (params["Dimension"].value == "Status Code") {
//for the select portion
this.queryText=this.queryText.replace("d.deln","s.stat_cod");
//for the group by portion
this.queryText=this.queryText.replace("d.deln","s.stat_cod");
// replace the from clause. AT THE BOTTOM
this.queryText=this.queryText.replace("left outer join delinquency d on f.deln_fk=d.deln_pk","left outer join statuscode s on f.stat_cod_fk=s.stat_cod_pk");
}</pre>
<p><span style="color:#006400;">Then I put the <strong>//replace the from clause</strong> code at the top and it works now!</span></p>
<pre class="_prettyXprint _lang-auto _linenums:0">
if (params["Dimension"].value == "Status Code") {
// replace the from clause. AT THE TOP.
this.queryText=this.queryText.replace("left outer join delinquency d on f.deln_fk=d.deln_pk","left outer join statuscode s on f.stat_cod_fk=s.stat_cod_pk");
//for the select portion
this.queryText=this.queryText.replace("d.deln","s.stat_cod");
//for the group by portion
this.queryText=this.queryText.replace("d.deln","s.stat_cod");
}</pre>
<p>Best Regards</p>
micajblock
<p>That is not the reason as the query does not get executed until the end of all the changes. Tell me if the attached works for you. All I did here is copy the below from the query in the text file to the beforeOpen script.</p>
<pre class="_prettyXprint">
left outer join delinquency d on f.deln_fk=d.deln_pk</pre>
<p>In any case I am glad it is finally working for you.</p>
xplorerdev
Sure. Thanks. But I just stepped out. I will try this on Monday morning and report.<br><br>
PS: My timezone is IST.<br><br>
Best Regards.
xplorerdev
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="146024" data-time="1479472560">
<div>
<p>That is not the reason as the query does not get executed until the end of all the changes. Tell me if the attached works for you. All I did here is copy the below from the query in the text file to the beforeOpen script.</p>
<pre class="_prettyXprint">
left outer join delinquency d on f.deln_fk=d.deln_pk</pre>
<p>In any case I am glad it is finally working for you.</p>
</div>
</blockquote>
<p> </p>
<p>I tried this Mica. But it ain't working. Same <span style="color:#ff0000;"><em>Multipart Identifier</em></span><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"> error.
What can possibly be wrong here? </span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">But I am relieved that its working with the change I did.
</span></p>
micajblock
<p>I am glad you got something working. I am still convinced there is something different in the characters otherwise the 2 elements in the attached design would be the same. If I am not mistaken there are multiple characters for "_". In any case I would use the attached design as a testing bed to test the code for text replacement. Good luck with the rest of your project.</p>