Dealing with Expressions in SSRS
Hi,
I have a requirement. My report looks like this
Name
Login Date
Response
Total Count
Yes Count
Dilip
2
30-Apr-11
YES
28-Apr-11
YES
Raza
2
28-Apr-11
YES
30-Apr-11
YES
Nagesh
1
28-Apr-11
NO
Prabhu
0
28-Apr-11
Kumar
3
30-Apr-11
YES
29-Apr-11
NO
28-Apr-11
YES
Please tell me how to calculate the count of "YES" for each name. For instance, Kumar's "YES" count should be 2. How can I achieve the same in an expression?
Thanks in advance,
Sharath
May 16th, 2011 2:50am
Name Login Date Response Total Yes Count
Dilip 2
30-Apr-11 YES
28-Apr-11 YES
Raza 2
28-Apr-11 YES
30-Apr-11 YES
Nagesh 1
28-Apr-11 NO
Prabhu 0
28-Apr-11
Kumar 3
30-Apr-11 YES
29-Apr-11 NO
28-Apr-11 YES
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 2:55am
Is it possible to use T-SQL?
select name,COUNT(CASE WHEN Response='YES' then 1 END)Yes_Total,
COUNT(*) Total
from tbl GROUP BY nameBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
May 16th, 2011 3:20am
I am using TSQL for the query. The problem is that I have already build the report and it has quite a number of fields. It'll be difficult to edit the query now. I was wondering if this can be done in an expression?
(PS-The query which you gave is indeed helpful. Can I include one more column called "TotalCount". How will the query be then? )
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 3:40am
Hello,
Try this expression.
=RunningValue(IIF(Fields!Response.Value = "Yes", 1 , 0 ), Sum, "GroupName")
Hope its helpful....Pavan Kokkula Tata Consultancy Services.
May 16th, 2011 4:44am
Hello Pavan,
In your expression, its not accepting the GroupName.
Is this the right way to give that? Or do I need to mention GroupName before the field value?
"Fields!Name.Value".
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 4:51am
Hello,
GroupName is the scope where you need to perform the task.
In your case you need to mention the name of the group (Name)
Hope its clear....Pavan Kokkula Tata Consultancy Services.
May 16th, 2011 11:42am