SSRS Count IF Multiple values

jhowe picture jhowe · Jun 17, 2014 · Viewed 32.2k times · Source

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.

Answer

Ian Preston picture Ian Preston · Jun 17, 2014

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.