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)
Calculate values from two table cells
cpfeil
Hello,
I am trying to calculate values from two different table cells in a third table cell (see attached screenshot).
The values which are calculated in table cell 1 and table cell 2 each have an own data set.
My problem is that I cannot access the data in the table cells.
Any ideas?
regards,
Christian
Find more posts tagged with
Comments
pricher
Christian,
You are not able to access the data directly because it is in two data sets. I think your only option is to use scripting, save the values you want to compute in variables, then display the result of the computation using a text item. Here's how to proceed:
In the initialize() method of your report, create 2 variables to hold the values of cell 1 and cell 2:
cell_1 = 0;
cell_2 = 0;
Then, on the onCreate() method of the aggregation for cell 1 and cell 2, add the following script:
cell_1 = this.getValue() //for cell 1
cell_2 = this.getValue() //for cell 2
To compute the proportion, use a Text Item with the following formula:
<VALUE-OF>cell_1/cell_2</VALUE-OF>
The only caveat with this method is that your computed field must appear to the right of where you display cell 1 and cell 2 because BIRT processes the table elements from left to right.
Hope this helps.
P.
mwilliams
Hi Christian,
In the onCreate of the cells, you can store the values in persistent global variables and then recall the values to add in the third element.
cpfeil
Hi,
Thank you pricher and mwilliams, this was a very helpful information.
I solved my problem after hours!
Thank you very much
regards,
Christian