Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count expression SSRS Report

Trying to count all rows in a column where column=Yes I have two columns in my report Accepted and rejected.

I'm trying to count the rows where accepted=Yes and do the say thing for rejected.

I've tried these:

=COUNT(IIF(Fields!accepted.Value="Y",1,0))
=COUNT(IIF(Fields!rejected.Value="Y",1,0))   
=COUNT(FIELDS!accepted.value="Y")
=COUNT(FIELDS!rejected.value="Y")

this expression is counting every row as opposed to just the ones that are "Y"

like image 500
Jt2ouan Avatar asked Mar 04 '13 15:03

Jt2ouan


People also ask

How do I use IIF in SSRS expression?

Using IIF Function in SSRS We are going to add a new field to the report data set to determine if the Order Year is the Max or Current Year. As shown below, the dataset properties window is opened, and the Fields tab is selected. After clicking Add, at the bottom of the list a new field is added.

How do I add expressions in SSRS report?

To add an expression to a text box For a simple expression, type the display text for the expression in the text box. For example, for the dataset field Sales, type [Sales] . For a complex expression, right-click the text box, and select Expression. The Expression dialog box opens.

How do I display the number of records in SSRS report?

Let me show you how I add the total number of rows in a SSRS table. I start by going to the Design layout tab. Next, select the table as shown in the above image. As I mentioned earlier, I want the text box to appear above the table in the left-hand corner.

How do you add a sum in Report Builder?

To add totals for a row group In the tablix data region row group area, right-click a cell in the row group area for which you want totals, point to Add Total, and then click Before or After.


2 Answers

You can do this a couple of ways:

SUM(IIF(Fields!accepted.Value="Y",1,0))

or

COUNT(IIF(Fields!accepted.Value="Y",1,Nothing))

COUNT is a count of all Rows, so even by returning 0 it will get included in the count. This is why returning Nothing should do the trick.

like image 92
Tom Jenkin Avatar answered Sep 23 '22 14:09

Tom Jenkin


=SUM(IIf(Fields!Doc_Type.Value = "Shipments", 1, 0), "YourDataSetName")

this worked for me with no errors. saw this on another post.

like image 43
bubbles Avatar answered Sep 22 '22 14:09

bubbles