Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Sum of RowsCount of Two Tables(DataSets)(How to get count of rows in two different tables(datasets) in the third table)
Sum of RowsCount of Two Tables(DataSets) [message #1696120] Fri, 22 May 2015 07:11
Kamal Subedi is currently offline Kamal SubediFriend
Messages: 1
Registered: May 2015
Junior Member
I have two tables, table1 and table2 within a container table, table_main in a report. These two tables have bindings to two different datasets.

I want to know the total result count of both tables' rows, inside the container table, which has binding to third dataset.

Is this possible?

How I tried to achieve this:
1. Defined two separate variables in report: RepVar1 and RepVar2.
2. Assigned each of the variable to the rowscount from each of the two tables.
3. Finally tried to sum the value of these two variables and assign it to a new field in the table_main.

The idea looks straightforward, but for some reason, i cannot assign the variables the values of rowscount. I have AGGREGATE fields on both the tables in the headers. On the onCreate event of AGGREGATE field, I have tried to assign their value to corresponding report variable, like below for the first one:

var abc = Number(this.getValue());
reportContext.setPersistentGlobalVariable("RepVar1",abc)

I have similar for the next aggregate field in table2 with the report variable being RepVar2.

Lastly, I created an integer field TotalCount in the table_main to get a sum of these two with the expression:

if(reportContext.getPersistentGlobalVariable("RepVar1")!=null && reportContext.getPersistentGlobalVariable("RepVar2")!=null)
{
Number(reportContext.getPersistentGlobalVariable("RepVar1")) +
Number(reportContext.getPersistentGlobalVariable("RepVar2"));
}
else
{
0;
}


I only get 0 even if there are records populated for the two tables, evidently by the fact that the AGGREGATE fields are populating rows count numbers.

Can anybody suggest what could have been gone wrong here?

Funny thing, if I then tried assigning these report variables in the Report initialize event as below and it works.

reportContext.setPersistentGlobalVariable("RepVar1","9")
reportContext.setPersistentGlobalVariable("RepVar2","2")

The TotalCount perfectly displays 11, as expected.

FYI, I am using the scripted datasets, but that shouldn't matter.

Thanks in advance.
Previous Topic:joining two tables in birt
Next Topic:Dynamic database adaption
Goto Forum:
  


Current Time: Tue Apr 23 11:16:31 GMT 2024

Powered by FUDForum. Page generated in 0.02917 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top