I'm trying to sum only group HourTarget totals.
7:00 8:00 HourTarget
Line 1 2715 1008 3224
A 2307 1008 3224
B 408 0 3224
Line 2 2308 2432 2656
A 2308 2432 2656
Line 3 2318 1622 2800
A 345 1258 2800
B 762 0 2800
C 1211 364 2800
I'm trying to achieve 8680 as a result of sum of HourTarget. But I'm getting 17504. It is because HourTarget in a database table is record for every single product running on this line, but the target is related to the line and not the product. How can I sum only the Group total?
Something like this is not working:
=Sum(Max(Fields!HourTarget.Value))
To add totals for a group, click Add Total on the shortcut menu for the group in the Grouping pane. To add totals for an individual cell in the tablix body area, click Add Total on the shortcut menu for the cell. The Add Total command is context-sensitive and enabled only for numeric fields.
You use groups. At the top click the insert menu, then table, then Table Wizard. Pick your dataset and hit next. Now drag the column for the different types of items you want a distinct sum of into the Row Groups section.
To open the Report Builder, select “Layout” From the “View” menu. Provide the fields in the dataset in a table by right-clicking ->insert -> table. To create a group, on the left side of the screen, right-click and choose Add Group ->Row Group ->Parent Group. Choose the required option for grouping.
Add total is disable if there is a expression or format string for value of cell. Just undo the expression and right click on the field you get it enabled and after adding total put your expression on the field agiain.
Since you are on SSRS 2008R2, you can use the aggregate of aggregate functionality that was added in that version.
You were on the right track; you just need to add a Scope value to your expression.
I'm using a version of your data, and have constructed a simple tablix:
Note that I have created a group called Line.
To get the Sum
of the Max
HourTarget column, use the expression:
=Sum(Max(Fields!HourTarget.Value, "Line"))
This works out the Max
for each Line group, then takes the Sum
of these.
Now we have your required value:
Prior to SSRS 2008R2 there was no easy way to do this; typically one would add an extra column to the DataSet with the pre-aggregated value to display in the report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With