# Sum field in a row

• ### Question

• Greetings, everyone!

I've got a little headache and I'm not quite sure how to solve it.

This is it:

I II III  IV

-------------

0 0 77 33
0 0 0   38
0 0 0   38
0 0 0   61
0 0 0   19

it's a table with four columns I, II, III and IV

I need to sum this columns horizontally to receive something like this:

I II III  IV  Sum

--------------------

0 0 77 33     110
0 0 0   38      38
0 0 0   38      38
0 0 0   61      61
0 0 0   19      19

I need to do it in a report... When I do it like this:

=Sum(Fields!I.Value + Fields!II.Value + Fields!III.Value + Fields!IV.Value +Fields!V.Value)

I receive the following result... why is that?

I II III  IV  Sum

--------------------

0 0 77 33     266
0 0 0   38      266
0 0 0   38      266
0 0 0   61      266
0 0 0   19      266

• Edited by Thursday, October 23, 2008 11:28 AM
Thursday, October 23, 2008 11:27 AM

### All replies

• When you call the "SUM" function, whatever fields you use it against will be totaled against the current scope of that field.   So saying "Sum(Fields!I.Value) is actually adding together the value of that field for ever row in  the current scope.   Scope being, current table, current group, or whatever the area is your placing the Sum at.

To do what you need to do, just drop the "Sum" off your expression

Living my life at 123mph in 11.15 seconds
Thursday, October 23, 2008 12:40 PM
• Hi, thanks! omg that so pretty obvious now! Thank you...

And now if I want to sum the total of this subsums? Like this:

I II III IV Sum

--------------------

0 0 77 33 110
0 0 0 38 38
0 0 0 38 38
0 0 0 61 61
0 0 0 19 19
---------------------
266

what is expression?

I know that I can use =Sum(Fields!I.Value + Fields!II.Value + Fields!III.Value + Fields!IV.Value +Fields!V.Value)

Here I'm referring to the fields from DataSource.

What if I want to sum all the cells above the current cell?

• Edited by Friday, October 24, 2008 4:38 AM
Friday, October 24, 2008 3:19 AM
• sum functions work off of a particular field and scope

If you have a table footer, and in that table footer  you put  Sum(Fields!I.value) it will give you the total for that field through the whole table.

If you use that same expression in a group footer, it will give you the sum of only those fields within that particular group.

Living my life at 123mph in 11.15 seconds
Saturday, October 25, 2008 10:52 PM