Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Sum

Status
Not open for further replies.

SchuhTL

Technical User
Dec 19, 2001
36
US
I need to sum the values (in detail section) where another column's value is = "value a" and ingore/don't sum where <> "value a". This sum is going in the group footer.

Payment Status
10.00 value a
12.00 value b
8.00 value c
10.00 value a

total: 20.00
 
I am not sure if Reporting Services has a way to do this, but one way you could is write your base query like:
Code:
SELECT Payment, Status,
       CASE Status WHEN "value a" THEN Payment END Payment_A
FROM   YourTable
That would make your final recordset look like
Code:
Payment  Status    Payment_A
10.00    value a   10.00
12.00    value b   NULL
 8.00    value c   NULL
10.00    value a   10.00
Then in your report, you would not actually show the new Payment_A column, but just reference it in a SUM in your footer: =SUM(Payment_A)

Perhaps this will work for you.
 
Thanks for the reply ookete... Here is a solution I found that seems to work.

I added a textbox in the footer and added this expression:

=Sum(iif(Fields!Status.value = "Value a", Cdbl(Fields!Payment.Value), 0.0))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top