SSRS using iff when dividing

旧巷老猫 提交于 2019-12-13 04:37:47

问题


I need to incorporate and iif statment in my expression. What I want to do is say if a field value = 0 then Fields!example1.value/Fields!example2.value else Fields!example1.value/Fields!example3.value. I hope that is clear in what I am trying to accomplish.


回答1:


You have to validate twice in order to keep your report safe of division by zero erros.

Try this:

=iif(
Fields!Field2.Value=0,
    iif(Fields!Field3.Value=0
    ,0
    ,Fields!Field1.Value/iif(Fields!Field3.Value=0,1,Fields!Field3.Value)),
Fields!Field1.Value/iif(Fields!Field2.Value=0,1,Fields!Field2.Value)
)


来源:https://stackoverflow.com/questions/33264428/ssrs-using-iff-when-dividing

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