Crystal Reports 中的求和组级别字段

xr2*_*0xr 5 grouping visual-studio-2010 crystal-reports

我正在尝试创建一个我认为应该非常简单的报告。我有一个与此类似的结果数据表:

ID    Amount    ChildID     Name    Discount
1     200       1           Billy   $10
1     200       2           Bobby   $20
2     100       1           Kenny   $10
Run Code Online (Sandbox Code Playgroud)

我需要从组行级别的金额中减去折扣总和。最后我需要总结这些金额。所以它看起来像这样:

ID: 1 Amount: $170
    Billy      $10
    Bobby      $20
ID: 2, Amount:$90
    Kenny      $10

Total:        $260
Run Code Online (Sandbox Code Playgroud)

我创建了一个公式,用于从团体金额中减去折扣总和。现在我如何在报告页脚中对这些值求和?

Rya*_*yan 3

您需要通过全局变量来跟踪正在运行的小计。像这样的组页脚公式应该可以做到这一点:

whileprintingrecords;
numbervar subtotal;

//Update subtotal with the group's amount minus the total discounts for that group
subtotal := subtotal + ({table.amount} - sum({table.discount},{table.ID}))
Run Code Online (Sandbox Code Playgroud)

在报表页脚中,您现在可以自由使用变量的总计。