嘗試:
=SUM(Fields!PaidLosses.Value)/
IIF(
ISNOTHING(
Lookup(Fields!YearNum.Value & Fields!MonthNum.Value,
Fields!YearStartRisk.Value & Fields!MonthNum.Value,
Fields!EarnedPremium.Value, "EarnedAllCoverages")
) OR
Lookup(Fields!YearNum.Value & Fields!MonthNum.Value,
Fields!YearStartRisk.Value & Fields!MonthNum.Value,
Fields!EarnedPremium.Value, "EarnedAllCoverages") = 0,1,
Lookup(Fields!YearNum.Value & Fields!MonthNum.Value,
Fields!YearStartRisk.Value & Fields!MonthNum.Value,
Fields!EarnedPremium.Value, "EarnedAllCoverages")
)
這是因爲你不能分割任意數量的零個或nothing
(SSRS空)
您也可以使用this great answer提供這種定製代碼安全地進行分裂造成的。
添加自定義代碼的textarea下面的代碼在Report
菜單/ Report Properties...
/Code
標籤
Public Function SafeDivide(ByVal Numerator As Decimal, ByVal Denominator As Decimal) As Decimal
If Denominator = 0 Then
Return 0
End If
Return (Numerator/Denominator)
End Function
然後在你的表矩陣只需要調用與分子和分母爲自變量的函數:
=Code.SafeDivide(
SUM(Fields!PaidLosses.Value),
Lookup(
Fields!YearNum.Value & Fields!MonthNum.Value,
Fields!YearStartRisk.Value & Fields!MonthNum.Value,
Fields!EarnedPremium.Value, "EarnedAllCoverages"
)
)
讓我知道這是否有幫助。
您是否嘗試過使用IIF來繞過無效值。 – FLICKER