开发者

Visual Studio Report Filtered Sum

I have a table in a Visual Studio 2008 Report (2005 .rdlc).

The table has a group, each group has a total and after all groups it has a grand total and looks something like this:

Group 1 |     A    |  B  |  C  |
----------------------------
        |     Bob  | 123 |  10 |   
        |     Tim  |  10 |   2 |  
        |  (Steve) | (43)|  (1)|  
Total                133

Group 2 |     A    |  B  |  C  |
----------------------------
        |     Jon  | 100 |  10 |   
        |     Kit  |  30 |   2 |  
        |  (Steve) | (83)|  (1)|  
Total                130

Grand Total          263

Steve is special and his numbers are shown but I don't want them included in any of the totals.

At the moment the Grand Total is an expression

sum(Fields!B.Value)开发者_如何学C

Is there anyway that I can filter out the sum? I have tried creating another group on the table which filters out rows where column A is equal to Steve, but when I try to sum I get an error:

sum(Fields!B.Value, "noSteveGroup")

Error 2 The Value expression for the textbox ‘textbox6’ 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.


There's no need for extra field. Just convert zero to type of your other field. Like this;

sum(iif(Fields!A.Value = "Steve", CDec(0), Fields!B.Value))


Turns out the sum function can accept some logic and doesn't need a constant column name.

I cannot do this

sum(iif(Fields!A.Value = "Steve", 0, Fields!B.Value))

But I can create a fake column full of zeroes and do this

sum(iif(Fields!A.Value = "Steve", Fields!Zero.Value, Fields!B.Value))

Not so elegant, but unless there are any other answers it will have to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜