views:

4119

answers:

2

I have an rdlc report file, and I am trying to make a sum which can only include the last item in each group. I have a table kind of like this:

Place                 = ?                              (Group header 1)
    User              = ?                              (Group header 2)
        Date          =Last(Fields!Number.Value)       (Group header 3)
            Number    =Fields!Number.Value             (Detail row)

So, in other words, in User there, I want a sum of Date... if that made sense...

The Numberrows contain many numbers per Date. But Date shows only the last number for that day, because the rest doesn't count (but must be displayed) In User I want to sum up those last numbers for all the dates for that user. And same with Place (which would be the sum of every last number for every day for every user).

Could anyone help me with this? I tried the obvious (to me at least) =Sum(Last(Fields!Number.Value)), but (also tried to specify the group in those functions, but didn't make a difference because) I get an error when I try to compile which says:

The Value expression for the textbox 'numberTextbox' 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.

Which I guess kind of makes sense... but how do I do this then?


Update: I have solved the issue by adding another column, and copying those last numbers into that column. This way I can display all the numbers, and do the summing on the column that only contains the ones that is going to be in the sum. I am still very curious to if anyone have a solution to my original problem though... so please post an answer if you do!

A: 

Not sure I understand exactly what you're trying to do. Maybe something like =Last(Fields!Number.Value,"Group 1") + Last(Fields!Number.Value,"Group 2") + Last(Fields!Number.Value,"Group 3"), instead using a sum function?

Mozy
Thing is that I have a dataset with a bunch of numbers. These numbers are all displayed in the detail rows. These numbers are grouped on date, then on user, then on location. And we need to have a Sum for each user and Sum for each location. Each location needs of course the sum of each user underneath it. And each location needs a sum of each date. but each date is only going to display the last number for that date (even though there can be many). So the user sum can not sum all the numbers in the group. only the last one from each date. Did that make sense?
Svish
Tried to make the question clearer.
Svish
Ok...so how about then using your example, =Last(Fields!Number.Value) is in "lastTextBox". And then =Sum(ReportItems!lastTextBox.Value). Am I closer to what you need?
Mozy
Well, in theory yes, but in practice I get the same error =/ "The Value expression for the textbox 'sumTextbox' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers." and "The Value expression for the textbox ‘sumTextbox’ 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."
Svish
A: 

the easiest way to do this would be to modify your dataset to only include the records your are displaying in the date field, that way you could just use a simple sum() instead of trying to do something weird and screwy and might not work.

DForck42
Yes, obviously, but then the others wouldn't be displayed, which they have to be =) Thing is that the numbers change during the day, and the report must display how they have changed. But in the sum, only the last of those numbers must be taken into account.
Svish
could i see your query? i have a vague idea of how to fix this, but i need something to visualize it with
DForck42
can't paste the whole linq query thing in here no. But the resulting rows are kind of like this: Place User Date Number1 Number2 Number3 Number4 TimeA TimeB TimeSpanAB. TimeA and TimeB must be displayd for each row, and the numbers also. But only the last number per date must be taken into account for the Sums.
Svish
well you could make it a part of the actual question, then you wouldn't have a size limit.
DForck42