Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsstore values in a Data Set to another
https://www.eclipse.org/forums/index.php/mv/msg/209561/671921/#msg_671921
Following the instructions from Jason in a previous post, I am conducting a series of tests to store values in a Data Set to another. I am having a problem to calculate the following ratio. I give you an example:
1. Data Set1: This dataset includes an aggregation (count) of Several items on a aggregate group (by product). Example:
product1 - 3
product2 - 2
product3 - 1
2. Data Set2: This Data Set should make another similar to the previous aggregation grouped by product. Example:
product1 - 3
product2 - 2
product3 - 2
3. My goal is to calculate the "Data Set2" the following percentages grouped also by product:
From which it follows that BiRT is only storing just one variable (the third result or "Data Set1: 1).
Can you tell me how I can store these 3 variables in the example in the "Data Set2? Where is the problem? Does aggregation introduced in the "Data Set 2 " or scripting?
Thanks]]>gin1975 2011-05-19T11:19:00-00:00(no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/671991/#msg_671991
as the name like:
reportContext.setGlobalVariable( row["product"], this.getValue());
This assumes that the aggregate is created once for each product. Then
just retrieve it the same way.
On 5/19/2011 7:19 AM, gin1975 wrote:
> Hello,
>
> Following the instructions from Jason in a previous post, I am
> conducting a series of tests to store values in a Data Set to another.
> I am having a problem to calculate the following ratio. I give you an
> example:
>
> 1. Data Set1: This dataset includes an aggregation (count) of Several
> items on a aggregate group (by product). Example:
> product1 - 3
> product2 - 2
> product3 - 1
>
> 2. Data Set2: This Data Set should make another similar to the previous
> aggregation grouped by product. Example:
> product1 - 3
> product2 - 2
> product3 - 2
>
> 3. My goal is to calculate the "Data Set2" the following percentages
> grouped also by product:
>
> product1: 3 / 3 = 100%
> product2: 2 / 2 = 100%
> product3: 1 / 2 = 50%
>
> For this, I tried to store the variables of "Data Set1" by scripting as
> follows:
>
> <method name="onCreate"> <! [CDATA [reportContext.setGlobalVariable
> (total1 "this.getValue ());]]></ method>
> name="resultSetColumn"> <property total_DataSet1 </ property>
>
>
> Then I inserted a "Data" with the following expression that seeks to
> calculate the percentage above mentioned:
>
> (reportContext.getGlobalVariable ("total1) / row [" total_DataSet2 "]) *
> 100
>
> Instead, the Report gives the following result:
>
> product1: 1 / 3 = 33.33%
> product2: 1 / 2 = 50%
> product3: 1 / 2 = 50%
>
> From which it follows that BiRT is only storing just one variable (the
> third result or "Data Set1: 1).
>
> Can you tell me how I can store these 3 variables in the example in the
> "Data Set2? Where is the problem? Does aggregation introduced in the
> "Data Set 2 " or scripting?
>
> Thanks]]>Jason Weathersby2011-05-19T14:17:20-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/672022/#msg_672022
gin1975 2011-05-19T15:33:08-00:00(no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/672029/#msg_672029
gin1975 2011-05-19T15:33:08-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674039/#msg_674039
When I send this parameter to the aggregation:
in those cases where it is null, the percentage instead of being zero, is 100. Is there any way to resolve this?
Thanks]]>gin1975 2011-05-25T16:13:18-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674040/#msg_674040
(reportContext.getGlobalVariable (row["products"])/row["total_items"])*100]]>gin1975 2011-05-25T16:15:15-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674069/#msg_674069
- If the total is 2 and the global variable is null, the percentage is 200
- If the total is 1 and the global variable is null, the percentage is 100.]]>gin1975 2011-05-25T17:44:58-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674078/#msg_674078
if( this.getValue() != null ){
}else{
}
Jason
On 5/25/2011 12:13 PM, gin1975 wrote:
> I found a problem in passing parameters in the following type of report:
>
> When I send this parameter to the aggregation:
>
> reportContext.setGlobalVariable variable (row ["product"], this.getValue
> ()),
>
> in those cases where it is null, the percentage instead of being zero,
> is 100. Is there any way to resolve this?
>
> Thanks]]>Jason Weathersby2011-05-25T18:12:17-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674228/#msg_674228
Hello,
Still not working. I explain with a simple example:
- I create total1 aggregation, which counts the items associated with a list of products
- Added the following line in the XML:
<method name="onCreate"> <! [CDATA [reportContext.setGlobalVariable (row ["products_name"], this.getValue ());]]></ method>
name="resultSetColumn"> <property total1 </ property>
- I create next Agregation_total2, which counts another set of items associated with a product list.
- I create Data Item "Percentaje", which must calculate the percentage between total1 and Total2.
The problem arises when the number of products recorded in total1 is not equal to those recorded in Total2. I explain with an example:
Percentage product1 = 1 / 1 = 100% OK
Percentage product2 = 2 / 2 = 100% OK
Percentage product3 = 1 / 2 = 100% NOK. This percentage should not appear as the product total1 3 is null.
I tried to include the following word in the data associated with percentage but does not work:
if (this.getValue ()! = null) {
(reportContext.getGlobalVariable (row ["products_name"]) / row ["Total2"]) * 100}
Can you tell me how I could try to fix this?
Thanks.]]>gin1975 2011-05-26T08:22:15-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674349/#msg_674349
For testing purposes add to the script like:
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/templ/mycalcs.txt", true ) );
out.println( "row value "+ reportContext.getGlobalVariable(
row["products_name"]));
out.close();
check the mycalcs.txt to see if the value is showing null. If it is
use
var top=0;
if( reportContext.getGlobalVariable( row["products_name"]) != null ){
top = reportContext.getGlobalVariable( row["products_name"]);
}
then use top in your calculation.
Jason
On 5/26/2011 4:22 AM, gin1975 wrote:
>
> Hello,
>
> Still not working. I explain with a simple example:
>
> - I create total1 aggregation, which counts the items associated with a
> list of products
> - Added the following line in the XML:
> <method name="onCreate"> <! [CDATA [reportContext.setGlobalVariable (row
> ["products_name"], this.getValue ());]]></ method>
> name="resultSetColumn"> <property total1 </ property>
>
> - I create next Agregation_total2, which counts another set of items
> associated with a product list.
> - I create Data Item "Percentaje", which must calculate the percentage
> between total1 and Total2.
>
> The problem arises when the number of products recorded in total1 is not
> equal to those recorded in Total2. I explain with an example:
>
> total1 product1 = 1
> total1 product2 = 2
>
> Total2 product1 = 1
> Total2 product2 = 2
> Total2 product3 = 2
>
> Percentage product1 = 1 / 1 = 100% OK
> Percentage product2 = 2 / 2 = 100% OK
> Percentage product3 = 1 / 2 = 100% NOK. This percentage should not
> appear as the product total1 3 is null.
>
> I tried to include the following word in the data associated with
> percentage but does not work:
> if (this.getValue ()! = null) {
> (reportContext.getGlobalVariable (row ["products_name"]) / row
> ["Total2"]) * 100}
>
>
> Can you tell me how I could try to fix this?
> Thanks.]]>Jason Weathersby2011-05-26T15:14:54-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674370/#msg_674370
row value 1
row value 1
value row 2
value row 2
row value 1
row value 1
This means that is repeated by calculating the total number of existing projects in total_2.
Thanks]]>gin1975 2011-05-26T16:42:24-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674375/#msg_674375
Is this a report I can run? If so can you post it?
Jason
On 5/26/2011 12:42 PM, gin1975 wrote:
> Mycalcs result file after making a test:
>
> row value 1
> row value 1
> value row 2
> value row 2
> row value 1
> row value 1
>
> This means that is repeated by calculating the total number of existing
> projects in total_2.
>
> product1_total1 = 1
> product2_total1 = 2
>
> product1_total2 = 2
> product2_total2 = 3
> product3_total2 = 2
>
> percentage1 = 1 / 2 = 50%
> percentage2 = 2 / 3 = 66%
> percentage2 = 1 / 2 = 50%
>
> How can we fix this?
>
> Thanks]]>Jason Weathersby2011-05-26T17:00:42-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674380/#msg_674380
]]>gin1975 2011-05-26T17:15:35-00:00Re: (no subject)
https://www.eclipse.org/forums/index.php/mv/msg/209561/674560/#msg_674560
Thanks]]>gin1975 2011-05-27T11:10:47-00:00