Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Global Variable and Crosstab
Frenkys
I use BIRT 2.6.2 with flat file (csv) and I have two crosstab. How can I put the Grand Totals (Row Area) of the first crosstab into global variables to use they on the second crosstab to make calculations?
Thanks
Find more posts tagged with
Comments
kclark
Are you wanting to sum all of the grand totals and then place that in a PGV or are you wanting to store them in an array to call them back for specific rows?
Frenkys
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="115280" data-time="1363882967" data-date="21 March 2013 - 09:22 AM"><p>
Are you wanting to sum all of the grand totals and then place that in a PGV or are you wanting to store them in an array to call them back for specific rows?<br /></p></blockquote>
I want to store them in an array to call them back, but there is a different method to sum all of the grand totals and then place that in a PVG?
kclark
You can store the values of grand totals in an array like this.<br />
<br />
From the onPrepare() of your report.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var crosstab1 = new java.util.ArrayList();
var crosstab2 = new java.util.ArrayList();
reportContext.setPersistentGlobalVariable("crosstab1", crosstab1);
reportContext.setPersistentGlobalVariable("crosstab2", crosstab2);
reportContext.setPersistentGlobalVariable("length1", length1);
reportContext.setPersistentGlobalVariable("length2", length2);</pre>
<br />
And then in onCreate() of each crosstab's grand total you will need to call back the array, add the value, then set it as a PGV again like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var crosstab1 = reportContext.getPersistentGlobalVariable("crosstab1");
crosstab1.add(this.getValue());
reportContext.setPersistentGlobalVariable("crosstab1", crosstab1);</pre>
<br />
and<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var crosstab2 = reportContext.getPersistentGlobalVariable("crosstab2");
crosstab2.add(this.getValue());
reportContext.setPersistentGlobalVariable("crosstab2", crosstab2);</pre>
<br />
Now you can pull back each value from the PGV. You can test this by displaying the value in a label from the onCreate()<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var test = reportContext.getPersistentGlobalVariable("crosstab1");
this.text = test.get(0);</pre>
Frenkys
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="115283" data-time="1363889062" data-date="21 March 2013 - 11:04 AM"><p>
You can store the values of grand totals in an array like this.<br />
<br />
From the onPrepare() of your report.<br />
<br />
...<br /></p></blockquote>
Thanks, it works. But now how can I get the array index of the second grand total in runtime to perform the calculations (ex. %, diff, ecc.)?
kclark
To get the second grand total it you would do something like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var tab1 = reportContext.getPersistentGlobalVariable("crosstab1");
var tab2 = reportContext.getPersistentGlobalVariable("crosstab2");
var summedValue = tab1.get(1) + tab2.get(1); // get(1) is the second value as the array starts at 0, this will sum the second value from both crosstabs</pre>
Frenkys
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="115331" data-time="1363973558" data-date="22 March 2013 - 10:32 AM"><p>
To get the second grand total it you would do something like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var tab1 = reportContext.getPersistentGlobalVariable("crosstab1");
var tab2 = reportContext.getPersistentGlobalVariable("crosstab2");
var summedValue = tab1.get(1) + tab2.get(1); // get(1) is the second value as the array starts at 0, this will sum the second value from both crosstabs</pre></p></blockquote>
My problem is another: I have the value of the crosstab1 (global total) on a array, then in report designer I have to use this array in the cells of the crosstab2 (global total and crosstab aggrgation cell). How must I use the array index? This array index, naturally, is different for every column of the aggrgation, but in designer I have only one column for the aggrgation cell and grand total.<br />
I hope I have described my problem well.<br />
Thanks
Frenkys
<blockquote class='ipsBlockquote' data-author="'Frenkys'" data-cid="115344" data-time="1364028936" data-date="23 March 2013 - 01:55 AM"><p>
My problem is another: I have the value of the crosstab1 (global total) on a array, then in report designer I have to use this array in the cells of the crosstab2 (global total and crosstab aggrgation cell). How must I use the array index? This array index, naturally, is different for every column of the aggrgation, but in designer I have only one column for the aggrgation cell and grand total.<br />
I hope I have described my problem well.<br />
Thanks<br /></p></blockquote>
No solution to this problem?<br />
Bye
kclark
Can you create a sample rptdesign showing what you are trying to do and post it?
Sameer Kumar
<p>What the **** is wrong with BIRT I'm wasting hours of time to get a minimum desirable output but it irritates like ****. SSRS is much better than this in terms of development</p>