一个新手问题,我找不到答案。
我有一个包含一个表格的报告,其中包含几个具有“时间”列的项目。我想按时间对项目进行分组,以便将同一个月的所有项目组合在一起。
为此,我必须从“时间”字符串(格式为“17:22 19/07/09”)中提取月/年,并将其用于分组。我知道如何在 Java 中完成所有这些工作,并且我认为 BIRT 提供了几种方法来做到这一点,但我无法找到一种简单的方法来做到这一点。
如果有一个很好的教程,我很乐意去看看。
谢谢!!
我们已经做到了如下。在我们对数据集的 SQL 查询中,我们同时选择(例如)"char(my_date,iso)"
和"left(char(date,iso),7)"
(分别为2009-01-05
和2009-01
),如下所示:
select
left(char(my_date,iso),7) as isoyyyymm,
char(my_date,iso) as isodate,
otherfield as value
from tbl
order by my_date
然后,当您在报告中创建表格时,第 1 列应该是基于 isoyyyymm 的分组列,并在表格中将该列留空:
所以你最终在设计器中:
+--------------------------------+-----------+-----------------+
| <Header row> | Date | Value |
+--------------------------------+-----------+-----------------+
| <Group header row (isoyyyymm)> | | |
+--------------------------------+-----------+-----------------+
| <Detail row> | [isodate] | [value] |
+--------------------------------+-----------+-----------------+
| <Group footer row (isoyyyymm)> | | Total.sum( |
| | | row["value"], |
| | | null, |
| | | "Grp1") |
+--------------------------------+-----------+-----------------+
报告表仍将按月份分组,但显示的详细信息行都将包含完整日期:
Date Value
---------- -----
2009-01-01 7
2009-01-08 2
2009-01-15 1
2009-01-22 4
-----
14
2009-02-05 2
2009-02-12 0
2009-02-19 0
2009-02-26 1
-----
5
如果你想这样做,你可以按间隔分组,但我们选择了最简单的方法来处理那些我们可以使用简单字符串的情况。显然,如果您的时间间隔是一周(或其他不适合简单字符串分析的时间),您将需要使用 BIRT 中内置的时间间隔分组。
最好的教程(在我看来)是BIRT,A Field Guide to Reporting的第 187 页(第 12 章) 。那,以及集成和扩展 BIRT是任何认真的 BIRT 用户的必备品。
This first is absolutely vital to any report designer. The second covers much more advanced topics such as embedded Java and Javascript, the report object model and the underlying architecture of BIRT. This is required if you want your reports to be truly spectacular.
此处包含日期时间解析的报告参数对您有帮助吗?
http://www.eclipse.org/birt/phoenix/deploy/viewerUsage.php#parameters
我有一份关于 BIRT Exchange DevShare 的示例报告,它可以做到这一点。你为它提供一个正则表达式(根据你的需要简单或复杂),它将使用正则表达式的匹配来创建组。
祝你好运!
This can be done with the group setting in the table itself. How to create groups is described in http://www.eclipse.org/birt/phoenix/tutorial/basic/basic06.php (btw., searching for 'birt table group' in Google gices this as the first hit). In this case you can do it like that:
This creates a grouped table without any SQL or JS fiddling.