BIRT - 从多个数据集中添加总计

发布于 2024-07-30 01:19:29 字数 529 浏览 1 评论 0原文

我在 BIRT 中有一份报告,我想在最后添加一个摘要。

该报告是 3 个具有自己的数据集的表。 我想显示第四个表,其中包含摘要信息和总计。 我无法计算总计。

前任:

DataSet #1
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx


DataSet #2
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx

DataSet #3
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx


Summary
Total DataSet #1 |  xx
Total DataSet #2 |  xx
Total DataSet #3 |  xx
Grand Total      | xxx

I have a report in BIRT and I want to add a summary at the end.

The report is 3 tables that have there own dataset. I want to show a fourth table with the summary information an a grand total. I have trouble calculating the grand total.

ex:

DataSet #1
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx


DataSet #2
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx

DataSet #3
col1 | col 2 | Total
   x |     x |     x
   x |     x |     x
                  xx


Summary
Total DataSet #1 |  xx
Total DataSet #2 |  xx
Total DataSet #3 |  xx
Grand Total      | xxx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮凉 2024-08-06 01:19:29

您已经在前三个表中创建了必要的小计(我猜是通过一个组)。 在为包含总计的表格单元格创建脚本事件中,设置一个持久全局变量来跟踪每个小计。 然后,您可以访问第四个也是最后一个表中的每个值。

要设置变量:

var totalValue = this.getDataRowData().getColumnValue("totalColumnName");
reportContext.setPersistentGlbalVariable("DataSet1Total", totalValue.toString());

注意:您需要将总计发送到“String”类型以确保序列化。 您可以在渲染最终汇总表时将其转换回数字。

要使用该变量,请将文本控件添加到报表中(在汇总表的单元格中)。 在文本控件的 onCreate 脚本事件中输入以下内容:

this.text = reportContext.getPersistentGlobalVariable("DataSet1Total");

您将为之前保留的每个汇总字段执行此操作。 然后,对于总计,您可以执行以下操作:

this.text = parseInt(reportContext.getPersistentGlobalVariable("DataSet1Total")) + parseInt(reportContext.getPersistentGlobalVariable("DataSet2Total")) + parseInt(reportContext.getPersistentGlobalVariable("DataSet3Total"));

持久全局变量只是一个可序列化的值,可以跨报表内的组件边界访问。 它可以非常方便地满足您的需求。

祝你好运!

You are already creating the necessary sub-totals in each of the first three tables (via a group I would guess). In the create scripting event for the table cell with your Grand Total, set a Persistent Global Variable to track each sub-total. You can then access each value inside the fourth and final table.

To set the variable:

var totalValue = this.getDataRowData().getColumnValue("totalColumnName");
reportContext.setPersistentGlbalVariable("DataSet1Total", totalValue.toString());

NOTE: You will need to send the grand total to a "String" type to ensure serialization. You can convert it back to a number when you render the final summary table.

To use the variable, add a Text control to your report (in a cell on the Summary Table). In the onCreate scripting event for the text control enter the following:

this.text = reportContext.getPersistentGlobalVariable("DataSet1Total");

You would do this for each summary field you retained earlier. Then for the Grand total, you can do this:

this.text = parseInt(reportContext.getPersistentGlobalVariable("DataSet1Total")) + parseInt(reportContext.getPersistentGlobalVariable("DataSet2Total")) + parseInt(reportContext.getPersistentGlobalVariable("DataSet3Total"));

A Persistent Global Variable is simply a serializable value that can be accessed across component boundaries inside a report. It can come in very handy for requirements just like yours.

Good Luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文