Crystal Reports 中的条件运行总计

发布于 2024-09-29 22:27:03 字数 541 浏览 15 评论 0原文

使用 VS 2008 Crystal Reports,我想对根据组更改计算的公式进行运行总计。当我单击“添加运行总计”时,此公式不会出现在“可用表和字段”列表中。

这是逻辑:

在更改组的组时

if CalculatedValue > 0 then
    ReportRunningTotal1 += CalculatedValue  
else
    ReportRunningTotal2 += CalculatedValue  

我可以在运行总计中指定条件吗?如果不是,我还能怎么做呢?

更多信息:我正在对数据库字段 BillableHours 的值进行名为 GroupRunningTotal 的运行总计。在更改组时,我将 GroupRunningTotal 与该组 MaxHours 的数据库字段进行比较,并在团体级别。

今天适用 - 把它想象成选举团 - 赢得选举的人并不取决于总票数,而是取决于选举团中的票数。

Using VS 2008 Crystal Reports, I would like to do a running total on a formula that is calculated on a group change. When I click on add a running total, this formula does not appear in the Available Tables and Fields list.

This is the logic:

On Change Group of group

if CalculatedValue > 0 then
    ReportRunningTotal1 += CalculatedValue  
else
    ReportRunningTotal2 += CalculatedValue  

Can I specify a condition in a running total? If not, how else could I do this?

More info: I am doing a running total called GroupRunningTotal of the value of db field BillableHours. At change of group, I am comparing GroupRunningTotal to a db field for that group MaxHours, and I display a result of MaxHours - GroupRunningTotal at the group level.

Appropriate today - Think of it like the electoral college - the person who wins the election does not depend on total number of votes, but of number of votes in the electoral college.

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

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

发布评论

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

评论(2

独闯女儿国 2024-10-06 22:27:03

我将您的问题解释为您想要将一个运行总计中的所有负值 (RT_Neg) 和另一个运行总计中的所有正值 (RT_Pos) 相加。怎么样:

  1. 生成RT_Neg运行总计。在要汇总的字段下,将您的 {Tbl1}.{Amount} 相加。在评估下,输入“{Tbl1}.{Amount}<0”作为您的自定义公式。切勿重置。

  2. 计算RT_Pos运行总计。在要汇总的字段下,将您的 {Tbl1}.{Amount} 相加。在评估下,输入“{Tbl1}.{Amount}>0”作为您的自定义公式。切勿重置。

  3. 在组页脚中插入两个运行总计(如果将它们放在页眉中,则可能无法正确求和)

,您可以:

  1. 创建一个自定义公式“If {Tbl1}.{Amount}<0 then {Tbl1}.{Amount} else 0”,并根据该公式计算运行总计。

我认为这两个选项之一将帮助您实现目标。

I'm interpreting your question to mean that you want to add up all the negative values in one running total (RT_Neg) and all the positive values in another (RT_Pos). How about this:

  1. Make the RT_Neg running total. Under Field to Summarize, sum your {Tbl1}.{Amount}. Under evaluate, enter "{Tbl1}.{Amount}<0" as your custom formula. Never reset.

  2. Make the RT_Pos running total. Under Field to Summarize, sum your {Tbl1}.{Amount}. Under evaluate, enter "{Tbl1}.{Amount}>0" as your custom formula. Never reset.

  3. Insert both running totals in the group footer (if you put them in the header, it may not sum properly)

Alternatively, you can:

  1. Make a custom formula "If {Tbl1}.{Amount}<0 then {Tbl1}.{Amount} else 0" and make a running total based off that.

I think one of these 2 options will get you to your goal.

岁月苍老的讽刺 2024-10-06 22:27:03

您很可能无法使用一个 RT 字段作为其他 RT 字段的条件。您可以使用公式,放置在组页脚上并评估“whileprintingrecords()”;在这些公式中,您可以分配/求和到一些变量中,并在报告末尾显示这些变量。关于如下(仅通用想法,您还需要初始化和显示例程):

numbervar rtcurrent := sum({somefield}, {groupfield});
numbervar rtplus;
numbervar rtminus;
if (rtcurrent > 0)
then rtplus := rtplus + rtcurrent
else rtminus := rtminus + rtcurrent;

You most likely cannot use one RT field as condition for other RT field. You can use formulas, placed on group footer and evaluated 'whileprintingrecords()'; in these formulas you can assign/sum into some variables and display these variables at the end of report. About like next (generic idea only, you need initialization and display routines as well):

numbervar rtcurrent := sum({somefield}, {groupfield});
numbervar rtplus;
numbervar rtminus;
if (rtcurrent > 0)
then rtplus := rtplus + rtcurrent
else rtminus := rtminus + rtcurrent;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文