Pentaho 简明教程
Pentaho - Functions
报表的每一页都包含一个 Page-header 区域和一个 Page-footer 区域。其余页面可供实际报表内容使用。
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.
让我们使用我们在前几章中使用的相同的 employee 表。将所有字段添加到报表工作区后,我们现在在页脚选项卡中添加一个函数来找出员工的最大年龄。
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)
查看以下屏幕截图。此处,结构窗格中的“数据”选项卡包含一个符号 fx(标记为“ 1 ”)。它是“添加”功能按钮。单击此按钮可向报表中添加不同的函数。
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
然后,您将会找到一个对话框,其中包含按不同组隔离的不同函数。若要打印页脚中的员工最大年龄,我们应该选择 Summary 组中的 Maximum 函数,该函数在以下屏幕截图中标记为“ 1 ”。选择它并单击 OK 。
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.

一旦您单击 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.
查看以下屏幕。最大化框包含两个指针(指针 1 和指针 2)。
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.
查看以下屏幕截图。它再次包含两个指针(指针 1 和指针 2)。
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 Name |
Purpose |
1 |
Open Formula |
Enables you to create your own custom Open Formula function using the built-in Formula Editor. |
2 |
Page |
Count the number of page used in report before rendering. |
3 |
Total Page Count |
List the total number of pages in the rendered report. |
4 |
Page of Pages |
Prints the current page number along with the total number of pages in the render report. |
Report Functions |
S.No. |
Function Name |
Purpose |
1 |
Is Export Type |
Tests whether the given export type has been selected for this report. |
2 |
Row Banding |
Alternates the background color of each item band in a group. |
3 |
Hide Repeating |
Hides equal values in a group. Only the first changed value is printed. |
4 |
Hide Page Header and Footer |
Hides the page header and footer bands when the output type is not pageable. |
5 |
Show Page Footer |
Only shows the page footer on the last page rendered in the report. |
Summary Functions |
S.No. |
Function Name |
Purpose |
1 |
Sum |
Calculates the sum of the selected numeric column. |
2 |
Count |
Counts the total number of items contained in a group. If no group is specified, all items in the entire report are counted. |
3 |
Count by Page |
Counts 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. |
4 |
Group Count |
Counts the total number of items in the selected groups. If no group is specified, all items in all groups are counted. |
5 |
Minimum |
Identifies the lowest or smallest value in a group. |
6 |
Maximum |
Identifies the highest or largest value in a group. |
7 |
Sum Quotient |
Performs simple division on the sum totals from two columns and returns a numeric value. |
8 |
Sum Quotient Percent |
Performs simple division on the sum totals from two columns and returns a percentage value. |
9 |
Calculation |
Stores the result of a calculation. This function is used in groups. |
10 |
Count of pages |
Counts items on a page according to the specified criteria. This value is reset to zero when a new page is reached. |
11 |
Sum of Pages |
Adds 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 Name |
Purpose |
1 |
Sum |
Calculates a running total sum of the specified column. |
2 |
Count |
Count the items in a group or in a report. |
3 |
Group Count |
Counts the number of groups in a report. |
4 |
Count Distinct |
Counts the distinct occurrences of a certain value in a column. |
5 |
Average |
Calculates the average value in a given column. |
6 |
Minimum |
Identifies the lowest or smallest value in a column. |
7 |
Maximum |
Identifies the highest or largest value in a column. |
8 |
Percent of Total |
Calculates the percentage value of a numeric column. The total sum is divided by the number of items counted. |
Advanced Functions |
S.No. |
Function Name |
Purpose |
1 |
Message Format |
Formats text according to the Java Message Format specification. |
2 |
Resource Message Format |
Formats text from a resource bundle according to the Java Message Format specification. |
3 |
Lookup |
Maps a string from one column to another string. |
4 |
Indirect Lookup |
Returns a value from a mapped field. |
5 |
Resource Bundle Lookup |
Performs a resource-bundle lookup using the value from the defined field as a key in the resource bundle. |
6 |
Open Formula |
Enables you to create your own custom Open Formula function using the built-in Formula Editor. |