ssrs 中总和的错误处理程序

Error handler for sum in ssrs

我有一个单元格,其中包含我的行值的总和。即=sum(Fields!amount.value)。有时,当 amount 包含非浮点值时,求和单元格将导致“#error”。当单元格处于“#error”状态时,我需要更改单元格的颜色。我该如何实现?

我想我会使用 IsNumeric() 检查值并查看是否有任何会导致错误的值。您可以只使用 Iif() 将布尔值转换为 1 或 0,然后使用 Sum() 来查看是否有任何值,然后将其作为 Textbox 属性中 BackgroundColor 字段的表达式输入。应该这样做:

=Iif(Sum(Iif(IsNumeric(Fields!amount.value), 0, 1)) > 0, "Red", "Transparent")

也就是说..."inspect the amount field, if it's not numeric return a 1. Add all those up, and if the total is more than 0 (meaning at least one of the values is not numeric, and thus you'll get #Error) turn the field red".