# how to sum a formula in SQL Reporting Services 2008

Hello:

Attached is an rdl.  I'm trying to produce a Grand Total for the "Sales Amt" column of this report.  (That column is the final column on the right.)

In that Sales Amt column, I already have a group sum.  And, the "Sales Amt" field itself in that column is a formula .

I need a grand total.  This will amount to a third field in this column.

How do I create this?

Apitech

Summary-Sales-By-Product2.txt
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Are you trying to Sum Sums?
0
Author Commented:
Exactly.  I know that there is not a way to do that.  But, that's how I was trying to explain it here in this posting.

The following is the group formula in SQL Reporting Services 2008 that sums the extended price column and specifically for each item class:

=Sum(iif(Fields!SOPTYPE.Value=4,
-Fields!XTNDPRCE.Value,
Fields!XTNDPRCE.Value))

Now, I want to do a “grand total” for this formula (on this column).  But, I cannot find the means to do this in SSRS.  I have tried doing a sum of that sum and I have tried the RunningValue function based on the textbox that this formula is in.  No dice.

Thoughts would be very, very much appreciated!

Apitech
0
Commented:
Api,

I know in BO I have to make separate variables for each Sum I had to cast the Sum ToNumber then Sum the Cast Results. I believe this is how I did it

First Step: As Variable
ToNumber ({@Sum FlxFstDisp})

Second Step: As Variable
Sum ({@FlexFstDispAmt})

0
Author Commented:
Do I place these into the Expression "area" of the field?  Are these formulas?
0
Assistant ConsultantCommented:
Put Sum in variable and use at last.
0
Author Commented:
Again, I ask "Do I place these into the Expression "area" of the field?  Are these formulas?"
0
Commented:
Yes these would be formula's in expression format using a variable in the variable editor.
0
Author Commented:
I'm still not seeing how this works.  Where is the "variable editor"?  Where do I place these formulas at?  How many variables do I creat?  How do I glean a "Grand Total" field (my ultimate goal) from definining variables?

I'm a total novice on how variables work in SQL Reporting Services 2008 (and 2005).  Could someone please methodically point out how I can get this accomplished?

I do appreciate the responses that I have received, thus far.  But, I do need step by step directions on this issue.

Thanks!  Again, it's very appreciated!

Apitech
0
Commented:
At the bottom of your screen in the Row Groups section right click the ItemClass row and select Add Total|After. This will give you a new total row. Right click the cell in the Sales Amt column on the Total row and choose Expression. Here you enter:
=sum(iif(Fields!SOPTYPE.Value=4,  -Fields!XTNDPRCE.Value,  Fields!XTNDPRCE.Value))
This should give you the total.
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Hi Nicobo!

That's exactly what I needed!  Thank you!!!!!!!!!!!!

That worked!!!

I was looking for something really simple like that!

Whew!  I was hoping that you would chime in on this!  Thank you, again, for doing so!

You're the best!

Apitech
0
Author Commented:
Nicobo is awesome!
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.