【问题标题】:SSRS - Grand Total of Group Expression TotalsSSRS - 组表达式总计的总计
【发布时间】:2012-10-12 00:18:13
【问题描述】:

我的组总数是一个表达式,它从数据集“dataset1”的[EquipmentName1] 组的第一个[Hours1] 值中减去最后一个[Hours1] 值。

我需要一个总计,每个设备的组表达式总计

我无法使用相同的公式从数据集“dataset1”的第一个 [Hours1] 值中减去最后一个 [Hours1] 值,因为。

如果我有 2 件设备,比如 Equipment1 和 Equipment2:

Equipment1 last [Hours1] = 10000 and first [Hours1] = 9500
Equipment2 last [Hours1] = 10500 and first [Hours1] = 10000

如果我使用从数据集 "dataset1" 的第一个 [Hours1] 值中减去最后一个 [Hours1] 值的公式,则公式将为 10500 - 9500

但是,我想要:

(10000 - 9500) + (10500 - 10000) = Grand Total

下面是尝试绘制我的表格的一部分

|_[Hours1]_|  =  Fields!Hours1.Value    
(e.g. 9500)

|___Expr___|  =  Last(Fields!Hours1.Value) - First(Fields!Hours1.Value) 
(e.g. 10000 - 9500 = 500)

|__________|  =  I need to total the value of Expr for all pieces of equipment

【问题讨论】:

    标签: sql-server-2008 reporting-services


    【解决方案1】:

    您需要使用一些自定义代码来实现。

    转到Report -> Report Properties -> Code 并输入

    Dim grandTotal As Integer;
    Function AccumulateTotal(value as Integer)
        grandTotal = grandTotal + value
        return value
    End Function
    
    Function GetTotal()
        return grandTotal
    End Function
    

    然后在需要调用累积函数的文本框上

    =Code.AccumulateTotal(Last(Fields!Hours1.Value) - First(Fields!Hours1.Value))
    

    然后在 Grand Total 文本框上调用 get total 函数

    =Code.GetTotal()
    

    【讨论】:

    • 警告:这在 SSRS 2208 R2 的 Reports web 查看器中不起作用,因为在每个新页面都会重置 grandTotal(我刚刚测试过)。
    • 我过去也做过的是使用组和报表变量以及隐藏表格来存储总数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多