Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 582
jhowe Avatar asked Jun 17 '14 10:06

jhowe


1 Answers

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.

like image 153
Ian Preston Avatar answered Sep 20 '22 14:09

Ian Preston