Subreports

Pentaho Report Designer (PRD) lets us add as many Subreports to our reports as necessary. This gives us a great hidden potential that we can use anytime.

Until now, we have seen that while various data sets can be defined in a report—for example, when we create Parameters—only one of them will be the principal data set that is, the one that contains the fields we will add to our report. Can you imagine what would happen if we could add two or more principal data sets to our reports? Imagine the quantity of related and unrelated information that our reports could display. Our report might look a lot like a dashboard.

With PRD we can move from internal manipulation of information (imagination) to reality by using Subreports.

Subreports in PRD

From a sci-fi point of view, we could say that by adding a Subreport to our main report, what we are doing is creating a portal to another report, just like in Stargate.

From a more formal perspective, we could say that a Subreport is a report within another report.

The layout, behavior, and use of a Subreport are similar to that of Reports. That is, we can configure its data set, add objects (label, textfield, chart, and so on), formulas, functions, and so on, but with the catch that we cannot add Parameters so that the end user chooses its values (the parameter values can be passed down from the main report to the Subreports).

Note

PRD lets us add as many Subreports as we need to our reports, and also lets us add Subreports within Subreports.

The relation between Reports and Subreports

PRD lets Reports and Subreports interact by using the import and export Parameters. These are internal Parameters that give the Report the ability to send information to its Subreports and vice versa.

For example, if you want to add a Subreport to the section Group Header that will display detailed information about the item under analysis, the Report should send this information to the Subreport so that the data set returns the information for this value. It works similarly to the conventional Parameters that we have already looked at.

The relation between sections of the Report and Subreports

The behavior of a Subreport will vary notably depending on what section of the Report it is placed in. This is because the Subreport will be executed each time the section of the Report it is found in is executed. For example, if a Subreport is placed in the Details section, the Subreport will be executed once for each row. If the Subreport is placed in the Group Header section, and this section is present only at the beginning, the Subreport will be executed once at the beginning of each group.

If we complicate things a bit and propose an example in which the Report uses groups and the Group Header section is repeated only once at the beginning of each group and we place a Subreport in this section, the Subreport will be executed just once at the beginning of each group.

Depending on the type of information that we want to display, we should choose in which section of the Report to place our Subreports.

Note

In the exercise that we do in this chapter, we include a Subreport in the Report Header section and another Subreport in the Details section. That way we can better understand their behavior.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset