Pentaho – Functions

Each page of a report contains a Page-header area and a Page-footer area. The remaining page is available for the actual report content.

The page footer tab is used to present some attributes and functions. For example, we can print the max value of the age field of an employee in the Page-footer. The reporting engine allows these features by using functions.

Let us use the same employee table which we have used in the previous chapters. After adding all the fields into the report workspace, let us now add a function into the Page-footer tab to find out the maximum age of an employee.

Follow the steps given below to add a predefined function to your report.

Step 1 – Click the Function Button (fx)

Take a look at the following screenshot. Here the Data tab in the structure pane includes a symbol fx (marked as “1”). It is the add function button. Click this button to add different functions into the report.

Step 2 – Select a Particular Function

Then, you will find a dialog box with different functions segregated into different groups. To print the maximum age of an employee at the page footer, we should choose the Maximum function in the Summary group which is marked as “1” in the following screenshot. Select it and click OK.

Once you click the Ok button, the function will be added to the Functions label in the Structure Pane which is placed at the right side of the screen.

Step 3 – Define a Field Name

Once you select the added function (i.e. Maximum), you will find another pane below the structure pane containing the properties of that function.

Take a look at the following screen. The maximized box contains two pointers (Pointer 1 and Pointer 2).

  • Pointer 1 − Select the function in the data tab of the structure pane.
  • Pointer 2 − Edit the Field name in the properties section by selecting the age field from the dropdown list. It is because we have to print the maximum age of an employee.

Step 4 – Add a Function to Report Workspace

Now, the function is ready with the customized properties. Now you can use that function in your report as a page footer attribute.

Take a look at the following screenshot. Again, it contains two pointers (Pointer 1 and Pointer 2).

  • Pointer 1 − Select and drag the Maximum function from the Structure pane to the page footer band in the workspace, as shown in the following screenshot. Now the design of your report is ready.
  • Pointer 2 − Select the Preview button on the left side of the screen.

Step 5 – Check Preview

Take a look at the following screen. It shows the preview of the report. The maximum age of an employee is marked and shown in a maximized box.

Pentaho – Additional Functions

The following table provides an additional list of functions that you can use in your reports.

Common Functions
S.No.Function NamePurpose
1Open FormulaEnables you to create your own custom Open Formula function using the built-in Formula Editor.
2PageCount the number of page used in report before rendering.
3Total Page CountList the total number of pages in the rendered report.
4Page of PagesPrints the current page number along with the total number of pages in the render report.
Report Functions
S.No.Function NamePurpose
1Is Export TypeTests whether the given export type has been selected for this report.
2Row BandingAlternates the background color of each item band in a group.
3Hide RepeatingHides equal values in a group. Only the first changed value is printed.
4Hide Page Header and FooterHides the page header and footer bands when the output type is not pageable.
5Show Page FooterOnly shows the page footer on the last page rendered in the report.
Summary Functions
S.No.Function NamePurpose
1SumCalculates the sum of the selected numeric column.
2CountCounts the total number of items contained in a group. If no group is specified, all items in the entire report are counted.
3Count by PageCounts the total number of items contained in a group on one rendered page. If no group is specified, all items on the entire page are counted.
4Group CountCounts the total number of items in the selected groups. If no group is specified, all items in all groups are counted.
5MinimumIdentifies the lowest or smallest value in a group.
6MaximumIdentifies the highest or largest value in a group.
7Sum QuotientPerforms simple division on the sum totals from two columns and returns a numeric value.
8Sum Quotient PercentPerforms simple division on the sum totals from two columns and returns a percentage value.
9CalculationStores the result of a calculation. This function is used in groups.
10Count of pagesCounts items on a page according to the specified criteria. This value is reset to zero when a new page is reached.
11Sum of PagesAdds all of the specified items on one page and produces a total. This value is reset to zero when a new page is reached.
Running Functions
S.No.Function NamePurpose
1SumCalculates a running total sum of the specified column.
2CountCount the items in a group or in a report.
3Group CountCounts the number of groups in a report.
4Count DistinctCounts the distinct occurrences of a certain value in a column.
5AverageCalculates the average value in a given column.
6MinimumIdentifies the lowest or smallest value in a column.
7MaximumIdentifies the highest or largest value in a column.
8Percent of TotalCalculates the percentage value of a numeric column. The total sum is divided by the number of items counted.
Advanced Functions
S.No.Function NamePurpose
1Message FormatFormats text according to the Java Message Format specification.
2Resource Message FormatFormats text from a resource bundle according to the Java Message Format specification.
3LookupMaps a string from one column to another string.
4Indirect LookupReturns a value from a mapped field.
5Resource Bundle LookupPerforms a resource-bundle lookup using the value from the defined field as a key in the resource bundle.
6Open FormulaEnables you to create your own custom Open Formula function using the built-in Formula Editor.

This Post Has 3 Comments

Leave a Reply