如何总结和重用复杂的数据集

发布于 2024-12-12 02:58:39 字数 1178 浏览 0 评论 0原文

如何在多个表中重复使用单个复杂数据集?

该数据集具有许多需要详细和摘要报告的计算列。这是一个非常简化的示例数据集:

is_food  sale_association  food_type  total_sold  total_associations  percent_total
1        Before Movie      Popcorn    50          3                   x BirtMath.safeDivide(...)
0        Before Movie      Soda       10          2                   x BirtMath.safeDivide(...)
1        During Movie      Jujubee    10          1                   x BirtMath.safeDivide(...)
0        After Movie       Soda       15          2                   x BirtMath.safeDivide(...)

从这个数据集中,我想创建所有食物类型的详细摘要,同时汇总非食物(使用“is_food”列),所有食物类型的另一个摘要,所有食物类型的另一个详细摘要 )

报告还包含一些需要计算的百分比(最复杂的表中为 6)(一些跨行,其他跨给定组中的所有行 ),所有这些都可以有分母为零,因此需要使用 safeDivide 进行防范(这是在源 SQL 查询中执行的 PITA,它本身正在执行聚合 - 当分子和分母都是和时检查除以零会导致毛茸茸的结果)查询)。

显然,我可以通过适当地关注 () SQL 查询来做到这一点,但是当我已经设法为最详细的数据创建怪物查询时,创建 12 或 15 个非常相似的查询似乎是浪费时间和精力。桌子。

似乎并不简单的是如何在表中执行汇总。我设法通过隐藏稍后汇总的行(例如示例中的“is_food == 0”)然后创建显示在页脚行中的自定义数据绑定来将某些内容组合在一起。它不仅感觉像是黑客攻击,而且还干扰了自然排序行的能力。再次回到这个例子,如果我按 Total_sold 排序并用 is_food == 0 汇总行,那么自然顺序应该是 Popcorn、Non-food、Jujubee。

BIRT wiki 中没有任何相关内容,“BIRT: A Field Guide, 3rd E”也没有。真正深入探讨这个话题。

How can I re-use a single complex dataset across a number of tables?

The dataset has a number of computed columns that needs to be reported both in detail and in summary. Here's a very simplified example dataset:

is_food  sale_association  food_type  total_sold  total_associations  percent_total
1        Before Movie      Popcorn    50          3                   x BirtMath.safeDivide(...)
0        Before Movie      Soda       10          2                   x BirtMath.safeDivide(...)
1        During Movie      Jujubee    10          1                   x BirtMath.safeDivide(...)
0        After Movie       Soda       15          2                   x BirtMath.safeDivide(...)

From this one dataset, I'd want to create a detailed summary of all food types while rolling up non food (using the 'is_food' column), another summary of all food types, another detailed summary of food with rolled up non-food by sale_association, etc. etc.

The report would also contain a number of percentages (6 in the most complex table) that need to be calculated (some across a row, others across all rows in a given group), all of which can have a zero value for the denominator and so need to be guarded against with safeDivide (which is a PITA to do in the source SQL query which itself is doing aggregation -- checking for divide by zero when both the numerator and denominator are sums leads to hairy queries).

Obviously I can do this by focusing the() SQL query as appropriate, but it seems like a waste of time and effort to create 12 or 15 queries that are very similar when I've already managed to create the monster query for the most detailed table.

What doesn't seem straightforward is how to perform the rollups in a table. I managed to hack something together by hiding rows that would later be summed up (e.g. "is_food == 0" in the example) and then creating custom data bindings that are displayed in a footer row. Not only does it feel like a hack, it also interferes with the ability to naturally order rows. Again, going back to the example, if I was ordering by total_sold and summarizing rows with is_food == 0, the natural order should be Popcorn, Non-food, Jujubee.

There's nothing in the BIRT wiki about this, nor does "BIRT: A Field Guide, 3rd E." really delve into the topic.

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

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

发布评论

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

评论(1

草莓味的萝莉 2024-12-19 02:58:39

这似乎是一个相当开放式的问题(尽管我同意重新使用单个数据集比使用多个查询以稍微不同的方式检索相同的数据更有意义)。一些一般性建议:

  • 使用所需数据的最详细版本作为每个 BIRT 报告项(通常是 BIRT 表)的通用数据集

  • 如果需要仅摘要级别报告,请将组添加到所需级别的 BIRT 表,根据需要将数据项添加到组页眉/页脚,并删除详细级别行)从BIRT 表。

  • 在某些情况下需要详细级别的报告(例如,对于食品项目,但不是非食品项目),请如上所述向 BIRT 表添加组,并设置详细信息行的可见性(在属性编辑器中 -属性 - 可见性)以选中隐藏元素,然后指定适当的表达式来抑制非必需行(本例中为非食品项目)。

通过选择整个表、选择属性编辑器中的“绑定”选项卡并单击“添加聚合...”按钮,可以将聚合(即汇总表达式)添加到表中。

This seems like a fairly open-ended question (although I agree that re-using a single dataset makes much more sense than having multiple queries retrieving the same data in slightly different ways). A few general suggestions:

  • Use the most detailed version of the data required as a common dataset for each BIRT report item (typically BIRT tables)

  • Where summary-only level reporting is required, add groups to the BIRT table at the desired level, add data items as required to the group headers/footers and delete the detail level row(s) from the BIRT table.

  • Where detail-level reporting is required in some cases (eg. for food items but not for non-food items), add groups to the BIRT table as above, and set the visibility of the detail row (in Property Editor - Properties - Visibility) to check Hide Element, then specify the appropriate expression to suppress the non-required rows (non-food items, in this example).

Aggregations (ie. summary expressions) can be added to tables by selecting the whole table, selecting the Binding tab within the Property Editor and clicking the Add Aggregation... button.

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