SSRS - Grand Total of Group Expression Totals

╄→гoц情女王★ 提交于 2019-12-11 02:26:00

问题


My group total is an expression which subtracts the last [Hours1] value from the first [Hours1] value of the group [EquipmentName1] of the dataset "dataset1.

I need a Grand Total the group expression totals for each piece of equipment

I am unable to use the same formula of subtracting last [Hours1] value from the first [Hours1] value of the dataset "dataset1" because.

If I had 2 pieces of equipment, say Equipment1 and Equipment2:

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

If I used the formula of subtracting last [Hours1] value from the first [Hours1] value of the dataset "dataset1" the formula would be 10500 - 9500

However, I want:

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

Below is an attempt to draw part of my table

|_[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

回答1:


You need to use some custom code to achieve that.

Go to Report -> Report Properties -> Code and type

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

Function GetTotal()
    return grandTotal
End Function

Then on the textboxes you need to call the accumulate function

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

And on the Grand Total textbox you call the get total function

=Code.GetTotal()


来源:https://stackoverflow.com/questions/12850524/ssrs-grand-total-of-group-expression-totals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!