Oliveira
Oliveira

Reputation: 1341

Can BIRT use the output of one table to another table - different datasets?

The issue Im having is:

I have a table with the output from one dataset X, in the output field I have an COUNT aggregation which returns me a number.

Want i want to do is: use this number in another table that already have another dataset Y, I want directly the final number treated by my aggregation COUNT. Table's Joints in this case are not useful because it will not return the 'number' treated. explanation

Upvotes: 0

Views: 4695

Answers (2)

hvb
hvb

Reputation: 2668

First rule: Always give your column bindings meaningful names (not just: "Aggregation", but "numRows" or something similar)!

Second rule: Report variables are global variables and as such they are considered bad practice - use them only if you don't find any other solution.

In the most common case you can put the table (based on data set) y into a detail row of table x. Then you can access the count using the syntax row._outer["numRows"]. And if you also need the count in the data set y, you can easily pass it as a data set parameter (use the "parameter binding" button in the binding tab).

You only need the report variable solution given by Dominique if (for any reason) your layout does not allow you to put table y inside table x's detail row.

Upvotes: 2

Dominique
Dominique

Reputation: 4332

A smart way to do this is to create a report variable to store the aggregation of dataset X. For example we name it aggregationX:

enter image description here

Once the variable is created, click the aggregation data in table X -> script -> onCreate

Enter this script:

vars["aggregationX"]=this.getValue();

You can then use vars["aggregationX"] in all expressions of report elements placed after aggregation X: in computed columns of dataset Y, data bindings of table Y, filters, sort expressions, highlight expressions, dynamic text etc.

Upvotes: 6

Related Questions