问题
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