I don't know how best to explain this but will try.
In my SSRS 2005 report, i have one group in my table. In that group, I have a field that for each company record in my dataset, this field value is repeated for each record. This is a transactions table so you'd expect several records in the dataset for each company..that's not the problem.
example data from dataset:
TransID CompanyID FeeGoal
1 1000 100
2 1000 100
3 1000 100
4 2000 400
5 2000 400
My SSRS 2005 Report has:
Group1 fields:
CompanyID FeeGoal
=Fields!CustomerNumber.Value =Fields!FeeGoal.Value
The output when previewed looks like this:
Company FeeGoal
1000 100
2000 400
Footer 209409730.83 (totals up all feegoals! not just unique instances!)
I have a footer, and this is where the problem comes in. I am not able to sum 100 + 400 because if I do a SUM(=Fields!FeeGoal.Value) It doesn't just sume up 100 + 400 but rather (100 + 100 + 100) + (400 + 400)
I can't find a way to sum up basically the top values for FeeGoal which is really what the Group Field is doing since I get 100 and 400 in my group field for feeGoal. I should end up with a total of 500 for my footer total for Fee Goal but not sure how to get this to work in this unique situation.
FYI: FeeGoal is an input from an ASP.NET form to allow managers to update that one column in my report so that other calculations can rely on it in my group fields. Once the user finishes, I run a stored proc to insert that fee goal in every customer transaction record / feegoal field
I guess is there a way to do some sort of Distinct SUM in an expression I also tried:
=SUM((Max(Fields!FeeGoal_AZ.Value)) / Fields!FeeSchedule.Value) * 100)
but you can't have an aggregate function like this, I get this error:
[rsAggregateofAggregate] The Value expression for the textbox 'GrossGoal_gt' contains an aggregate function (or RunningValue or RowNumber functions) in the argument to another aggregate function (or RunningValue). Aggregate functions cannot be nested inside other aggregate functions.
Build complete -- 1 errors, 0 warnings

SUM problem in SSRS 2005 report
Chintan Soni
Shawn Burke - MS
Bhavin Vyas
nards_ocampo
I'm having the same problem. First let me say that I'm an old hand with SQL (circa version 4 '94) but I'm quite new with report service and I find that examples are fairly lacking in bol.
Report needed
Drill down of employee time in a company: Division, person, date, time in, time out, task and finally task time.
So there's 2 unequal group I want to sum: Out minus In and Task Duration.
I know how to do it in SQL (Sum(distinct ... )but I want to use the nifty group collapsing of SSRS, start by showing division summaries for user to drill down. It really makes then feeling empowered!
I'm feeding a pretty dum flat-file like dataset to SSRS, that of course, repeats DayIn and DayOut for each task in the day. In SSRS,I Have defined Hierarchical groups: Department, Employee, Date. Tasks ends up in the detail row
When I try to sum things up: Bam! if there's 5 task on a 12 hours day, I get the correct task time but that day ends up with 60 hours.
Now I tried using sum and running values with scope. Doesn't work.
It's a bit frustrating. There's a countDistinct function so where's the sum distinct
So what I would like to ask here is either a working sum distinct function or a better way to achieve the desired drill down effect - both via SSRS.
The T-SQL way to do it I know very well.
Thank you in advance
Rickahooy
You may have two options:
- use the "distinct" in your sql source
- try SUM(Fields!FeeSchedule.Value,"yourtablegroup")
Regards
Ayzan
John Calcote
use query as shown below
Select companyID,sum(FeeGoal)/count(*) from Table
group by companyID
this returns
CompanyID FeeGoal
1000 100
2000 400
and u can always use sum function to sum up the fee goal
hope this helps
Macka007007
distinct won't help me in this case because the dataset is based on a set of records, Distinct won't make a difference.
So you're saying that in an SSRS 2005 table, my footer can access field names in the same table I kept getting errors when I tried to do that using ReportItems! but maybe your way will work ! ! !
I'll try it
Teo
Comsin
HEY GUYS, this is SSRS Expressions, not SQL!
walt
Below is the code to put in the Custom Code part:
Public sum_of_feegoal As Integer
Public Function SumUp(ByVal Value As Integer)
sum_of_feegoal = sum_of_feegoal + Value
End Function
then add a textbox next to your Fee Goal textbox that will have the following code:
=Code.SumUp(ReportItems!FeeGoal.Value)
then to output the sum, use the following code:
=Code.sum_of_feegoal
Hope this help.
Daren
Nicolai G. Andersen
Yea, well, I am not coding this calculation in SQL, it is gonna be a nighmare, this cacluation contains about 10 others wrapped up that you don't see....SQL isn't set out for this code...so that option is not one for me here.
also, I can't assume that's you you meant, all you showed me was SQL, you didn't state put that in a dataset...I can' assume everything you're thinking here, you need to be more specific.
SSRS should be able to handle this, I'm not coding that calculation in SQL, that's just not viable in this report just for one darn sum....that's ridiculous. SQL can do calculations but the one I would have to do is outrageous for SQL to handle and would give me a migrane. That's why I want to use OO or SSRS functions since that is more suited to get this sum done but SSRS can't simply reference a group field from footer, that's ridiculous.
I have to take in account commission % which I cannot just Sum up a % across the board for the GT. I have to take in consideration each value in the group and let those multiply but the commission %, then sum on that colum to get a true GT down the line.
Parky
Well, I've decided to resolve this via t-sql after all. Problem can also be stated as that there is 2 different ranges in main dataset.
So I added a subquery that counts task per day and I'm dividing daily duration by that number. I end up with only one range and it just become a matter of putting my sums in the correct groups.
dpomerantz
i know that u r using ssrs.
what i meant was, to use the query to generate the dataset and not in ssrs.
jbothwel
Unless I'm doing this wrong, there's no way to do what you're saying. When I try to preview this report, it errors out on my footer field:
[rsInvalidAggregateScope] The Value expression for the textbox ‘GrossGoal_gt’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.
Build complete -- 1 errors, 0 warnings
My expression is:
=SUM(Fields!GrossGoal1.Value,
"CustomerNumber_Grp")