Count expression SSRS Report
Asked Answered
H

3

22

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"

Harbourage answered 4/3, 2013 at 15:2 Comment(0)
S
48

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.

Subsoil answered 4/3, 2013 at 15:10 Comment(1)
Thanks. I was overthinking the count, I didn't want to sum them but that makes sense as I'm converting if its Yes to a 1Harbourage
A
3

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

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

Ansela answered 21/7, 2017 at 16:6 Comment(0)
T
0

You can try to use "And" Operators to check both conditions together.

=COUNT(IIF(Fields!accepted.Value ="Y" And Fields!rejected.value="Y",1,0))
Trod answered 28/5, 2019 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.