简体   繁体   English

我有一个无法正常工作的自定义 SSRS 表达式

[英]I have a custom SSRS Expression that is not working properly

I have a custom SSRS expression to calculate percentage:我有一个自定义 SSRS 表达式来计算百分比:

=IIF(Sum(Fields!BidTotal.Value)=0,0,Sum(Fields!Bid_Margin.Value)/Sum(Fields!BidTotal.Value))

However when I go to preview the report I keep receiving the #Error message, due to diving by zero, but the IIF statement should resolve this.然而,当我去预览报告时,我不断收到 #Error 消息,由于跳零,但 IIF 语句应该解决这个问题。 I'm using the same formula for other fields and it's working as intended, not sure why this expression would be any different.我对其他字段使用相同的公式,它按预期工作,不知道为什么这个表达式会有所不同。

Unfortunately, SSRS evaluates both sides of the IIF regardless of the outcome of the initial expression.不幸的是,无论初始表达式的结果如何,SSRS 都会评估 IIF 的两边。

You just need an extra IIF to make it complicated enough so that it doesn't find an issue.你只需要一个额外的 IIF 让它足够复杂,这样它就不会发现问题。

=IIF(Sum(Fields!BidTotal.Value) = 0, 0, Sum(Fields!Bid_Margin.Value))  
 /
 IIF(Sum(Fields!BidTotal.Value) = 0, 1, Sum(Fields!BidTotal.Value))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM