jhowe
jhowe

Reputation: 10828

SSRS Count IF Multiple values

I'm creating an education report. I have a bunch of grades and I would like to sum the number of grades A - C. Something like

SUM WHERE Grades IN ('A', 'B', 'C')

How do I do this in an expression? Can I do a SUM on a Choose statement or something? I tried =SUM(Choose(1, "A", "B", "C")) but I couldn't get it to work.

Upvotes: 11

Views: 42019

Answers (2)

Sivarat Praditkul
Sivarat Praditkul

Reputation: 1

I think you need to replace 0 with Nothing. like below,

=Sum(
    IIf(Fields!Grades.Value = "A"
        or Fields!Grades.Value = "B"
        or Fields!Grades.Value = "C"
    ,1
    ,Nothing)
)

Then you should be good to go.

Upvotes: 0

Ian Preston
Ian Preston

Reputation: 39566

You need to combine a Sum statement with an conditional statement like IIf:

=Sum(
    IIf(Fields!Grades.Value = "A"
            or Fields!Grades.Value = "B"
            or Fields!Grades.Value = "C"
        , 1
        , 0)
    )

This way the count is only included in the Sum if Grades is A or B or C.

Upvotes: 24

Related Questions