Pentaho 简明教程

Pentaho - Groups

Pentaho 提供各种功能和特性,可将原始数据转换成有意义的信息。在此,我们将了解如何使用其中一项功能 Groups 。您可以使用此功能将原始行集数据分隔到组中,以便用户轻松理解报表。

Pentaho offers various functionalities and features to convert raw data into meaningful information. Here, we will learn how to use one such feature Groups. You can use this feature to segregate raw row-set data into groups so that the user can easily understand the report.

  1. Grouping is a great way to divide long lists of data along meaningful separators.

  2. With groups, you can keep similar items together and visually separate these items from other groups of items.

  3. You will also need groups to perform various aggregations over the data, like printing the number of items in a group or calculating sums or averages.

Adding Groups in Pentaho

我们已经有一个基于员工数据的报告了。这里的查询是根据“部门”对所有员工记录进行分组。按照下面给出的步骤来满足给定的要求。

We already have a report based on the employee data. Here the query is to group all employee records according to "department". Follow the procedure given below to fulfill the given requirement.

首先,通过单击结构窗格上的 Add group 按钮来启动流程。 Add group 按钮在以下屏幕截图中标记为“1”。

First of all, you start the process by clicking the Add group button on the Structure pane. The Add group button is marked as "1" in the following screenshot.

add group

单击添加组按钮,您将获得一个选项列表。然后,从列表中单击 Add group 选项。

You will get a list of options by clicking the Add group button. Then, click the Add group option from the list.

单击添加组后,您将发现一个对话框,您可以使用该对话框从给定的可用字段中添加组字段。

After clicking Add Group, you will find a dialogue box using which you can add a group field from the given available fields.

查看以下屏幕截图。我们在对话框中突出显示了三个活动,我们将其标记为 1、2 和 3。

Take a look at the following screenshot. The three activities are highlighted in the dialog box which we have marked as 1, 2, and 3.

  1. Pointer 1 − Enter a user-defined name for this group.

  2. Pointer 2 − Select the department field from the available fields list.

  3. Pointer 3 − Click the arrow () button so that the selected field gets copied to the selected Fields list.

在选定的字段列表中选择该部门字段,然后单击确定进行确认。

Select that department field in the selected fields list and click OK to confirm.

add group 1

添加组后,您将在结构窗格的结构选项卡中找到它。您还将在工作区中找到 Group HeaderGroup Footer 带。

After adding the group, you will find it in the Structure tab of the Structure pane. And you will find the Group Header and Group Footer bands in the workspace.

查看以下屏幕截图。通过将报表设计器左侧调色板上的标签图标拖到组头中,为您的报表添加一个静态标签(在屏幕截图中,此活动已标记为“ 1 ”)。

Take a look at the following screenshot. Add a static label to your report by dragging the label icon from the palette on the left side of the Report Designer into the group header (in the screenshot, this activity has been marked as “1”).

通过双击标签,您可以对其进行编辑并将名称更改为 Department 。通过使用格式化工具栏或格式化调色板(分别标记为“3”和“4”),您可以更改标签的格式。

By double-clicking the label, you can edit it and change the name to Department. By using the Formatting Toolbar or the Formatting Palette (marked as "3" and "4" respectively), you can change the format of the label.

data tab

现在让我们继续进行。将结构窗格切换到数据选项卡。从结构窗格中选择部门字段并将其拖动到组头(此活动在以下屏幕截图中标记为“ 1 ”)。要查看报表的预览,请单击屏幕左侧的预览按钮,该按钮在以下屏幕截图中突出显示并标记为“ 2 ”。

Let us now proceed further. Switch the Structure pane to Data tab. Select and drag the department field from the Structure pane to the Group Header (this activity is marked as “1” in the following screenshot). To see a preview of your report, click the preview button on the left side of the screen which is highlighted and marked as “2” in the following screenshot.

result report

单击预览按钮后,您将找到结果报告,如图所示以下屏幕截图所示。您会发现记录现在已按部门分组。

After clicking the preview button, you will find the result report as shown in the following screenshot. You will find the records have now been grouped together according to department.

records

此时的报表看起来不太吸引人。您可以使用格式化工具栏或格式化调色板添加一抹色彩并使标题更具效果。

The report does not look very appealing at this stage. You can add a touch of color and make the heading more effective using the Formatting Toolbar or the Formatting Palette.

你现在已准备好使用 Pentaho 生成不同类型的报表。只需按照迄今为止讨论的步骤操作,并尝试使用 Pentaho 中提供的所有功能和选项即可。

You are now ready to generate different types of reports using Pentaho. Just follow the steps discussed so far and try to use all the features and options available in Pentaho.