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)
Dynamically parsing the row of dataset
Birt_newbi
Hi,<br />
<br />
I am new to BIRT I am trying to sum up the values of a numeric field from a subquery that is union. The subquery actually produces 2 data rows, that looks like this<br />
row 1 = A , 30<br />
row 2 = B, 50<br />
<br />
I have bound this subquery to a table . I need to display the total value of <br />
(30 + 50) in one line but it is not working. I have tried the following approach:<br />
•Initialized a sum varaible called (oblamoun = 0) at the "onCreate" method of the table that is associated with this dataset. <br />
<br />
•Initialized the global variable called sumoblgfinal at the "Before Factory" method.<br />
<br />
•Selected the detail row for this table and added the following code on the onCreate event:<br />
<br />
row = this.getRowData();<br />
oblamount += row.getExpressionValue("row[TOT_OBL]");<br />
reportContext.setGlobalVariable("sumoblgfinal", oblamount);<br />
<br />
•To test this calculation I am have tried to display the out by associating it to a label object by assigning the following code to the "onCreate" event.<br />
<br />
this.text = sumoblgfinal;<br />
<br />
This approach is not working though. I also tried changing the Global variable to PersistentGlobalVariable but did not work either. Isn't there a simple BIRT equivalent for <br />
<br />
For(i=0; i<total_count; i++)<br />
{<br />
total_sum = total_sum + row
.amt<br />
}<br />
<br />
So far all that I could find is this:<br />
<br />
for (count = 0; count < Total.count(); count++){<br />
num = row["NVL(SUM(T.DLLR_AM),0)"];<br />
sum+= parseInt(num);<br />
}<br />
<br />
Is there a way to force the row to point to next row in a given dataset ? Could you please help?<br />
<br />
Thanks<br />
<br />
Shalini
Find more posts tagged with
Comments
Virgil Dodson
Are your two rows related by anything so you can combine them together with table grouping?<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/344-birt-combine-rows/#description'>BIRT
Combine Rows - Designs & Code - BIRT Exchange</a><br />
<br />
Otherwise, is it possible to create two different data sets... with a common row key so that BIRT can join the two with a Joint Data Set?<br />
<br />
You should run the enclosed report design that logs the event order that BIRT uses. Look at the Scripts in the Report Outline to see where it is writing the log file. In your case, the next row will not yet be available on a table row... but the previous row might be.
Birt_newbi
Hi Virgil,
Thanks for your response but the sample report that you have sent is 3.2.1.6 is not supported by my current BIRT platform.
To answer your other question about breaking it up into different data sets, Well at this time it is not an option. This report is very complicted and needs a lot of calculation and making of summaries. Even if let's say theoretically I separate them out into different data sets I should still be able to add their results. Is it possible to do mathematical operations using Global variables ? So far I have not been able to do it.
Virgil Dodson
There is an older version of the Event Order report design at <a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/339-birt-advanced-report-and-chart-scripting-examples/#description'>BIRT
Advanced Report and Chart Scripting Examples - Designs & Code - BIRT Exchange</a> <br />
<br />
As for doing math on the global variables, you will need to convert those stored objects into something like an Integer with code similar to below.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var tmpi = parseInt(reportContext.getGlobalVariable("ordersumsgbl"), 10);
tmpi += parseInt(this.getRowData().getColumnValue("QUANTITYORDERED"));
reportContext.setGlobalVariable("ordersumsgbl", tmpi);
</pre>