Divide by zero error in SSRS Report

北战南征 提交于 2019-12-11 13:17:49

问题


I am writing a report in SQL Server 2005 Reporting Services, involving the division of money values that might be equal to zero. I put the following code in to check for a zero denominator:

=IIf(Sum(Fields!PreviousPremiumMTD.Value) = 0, "N/A", FormatPercent((Sum(Fields!PremiumMTD.Value) / Sum(Fields!PreviousPremiumMTD.Value))-1, 0))

However, for some reason I am still getting #Error displaying on my report with the following warning thrown:

[rsRuntimeErrorInExpression] The Value expression for the textbox ‘textbox62’ contains an error: Attempted to divide by zero.

Any assistance is greatly appreciated.


回答1:


IIF evaluates the expression before passing that to function, thats why you will always get the DivideByZero error here.

See an example post: http://secretgeek.net/iif_function.asp



来源:https://stackoverflow.com/questions/10322773/divide-by-zero-error-in-ssrs-report

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