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)
Calculating aggregate on data cube totals
paqman
Hey BIRT folks,
I have a report I'm working on, where I have a crosstab displaying 3 columns per column grouping. In the dataset feeding the data cube, I am dividing the first column by the second one, and outputting this in the 3rd column of the crosstab:
Find more posts tagged with
Comments
kclark
You will need to add the values of target an actual to a PGV from the onCreate().<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("value1", this.getValue());</pre>
<br />
and<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("value2", this.getValue());</pre>
<br />
Then you can use a label in the third column. You'll use a script like this to recall the PGV's, divide the two, and display the value.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var value1 = reportContext.getPersistentGlobalVariable("value1");
var value2 = reportContext.getPersistentGlobalVariable("value2");
this.text = parseFloat(value1) / parseFloat(value2);</pre>
paqman
Which element should I be adding the onCreate script to? I've tried both the data element and the crosstab cell, and neither are updating the variable (it just shows its default value of 0).
kclark
Here's a better way to do this. Click on the difference in your totals (90.93%) and delete it. Then drag a data item from the palette in it's place. Then you can select it to be a float and choose Target_group/Month and Actual_Group/Month from the expression editor to have an expression like this.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>data["Target_Group/Month"]/data["Actual_Group/Month"]</pre>
paqman
Perfect! I didn't realize I could reference those column values from a data binding directly. Thanks for the help