SSRS Count IF Multiple values

时光怂恿深爱的人放手 提交于 2019-12-01 15:55:52

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/24260991/ssrs-count-if-multiple-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!