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)
Sum the value of 2 elements from 2 differents dataset in one grid
basami
<p>Hello everybody;</p>
<p> </p>
<p>I need to make a simple addition between 2 elements in my grid.</p>
<p>I <span style="font-size:14px;">have 2 cells </span>in my grid and each cell contains a float value from 2 differents dataset (1 dataset by cell).</p>
<p> </p>
<p>I<span style="font-family:arial, helvetica, sans-serif;"> want to sum these 2 values (the value is a simple number not list), I tried to set 2 global variables with the 2 values with </span>method <em>reportContext.setPersistentGlobalVariable() <span style="font-size:14px;">, </span></em><span style="font-size:14px;">but I cannot find how to perform it.</span></p>
<p> </p>
<p><span style="font-size:14px;"><span style="font-family:arial, helvetica, sans-serif;">Can you please help me on this issue?</span></span></p>
<p><span style="font-size:14px;"><span style="font-family:arial, helvetica, sans-serif;">Thanks in advance​​</span></span></p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>You can use a Report Variable to store the values you want to add.</p>
<p> </p>
<p>1. Create a Report Variable called <span style="font-family:'courier new', courier, monospace;">vTotal</span> and initialize it to <span style="font-family:'courier new', courier, monospace;">BirtMath.add(0,0)</span>. This will ensure that the variable has the right type.</p>
<p>2. In the onCreate method of each data item you want to add together, add the following script: <span style="font-family:'courier new', courier, monospace;">vars["vTotal"] = BirtMath.add(this.getValue(),vars["vTotal"]);</span></p>
<p>3. Then display the value of the variable in a text item: <span style="font-family:'courier new', courier, monospace;"><VALUE-OF>vars["vTotal"]</VALUE-OF></span></p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
basami
<p>​Hi,</p>
<p> </p>
<p>It displays 0.</p>
<p>I tried with another dataset element and it works very well. I noticed that I forgot to state that my data items for each cells are computed colums.</p>
<p> </p>
<p>My 2 data items that I want to sum together are computed colums integer type that used COUNT function on specific row expression from dataset</p>
pricher
<p>Can you send your report design?</p>
basami
<p>Finally I resolved this issue. the variable results needs to be used after the loading of the method this.getValue(). I tried to display the variable vTotal at left of my data items and it doesn't display anything but at the right of my data items it works.</p>
<p> </p>
<p>Thank you for your help</p>