【问题标题】:IsNothing not working on empty value in report builderIsNothing 在报表生成器中无法处理空值
【发布时间】:2013-07-07 10:06:14
【问题描述】:

我在表中有一个表达式,用于检查是否有返回值。

如果查询返回空或null我想将值设置为0

=IIF(IsNothing(Fields!DndCount.Value),0,Fields!DndCount.Value)

但是如果查询返回空IsNothing()就不行了。

【问题讨论】:

  • DndCount 的数据类型是什么?它是一个字符串吗?对于计数字段,我希望它是一个 int,它没有 empty 的概念;要么是NULL,要么不是。
  • 数据类型是int,在某些情况下查询返回零行,在这种情况下如何将值设置为“0”。
  • 这个表达式是用在细节行还是页眉/页脚行中?

标签: reporting-services ssrs-2008 report reportbuilder3.0


【解决方案1】:

我已经尝试过这段代码,它对我有用。

IIF(Sum(Fields!DndCount.Value)Is Nothing, "0", Sum(Fields!DndCount.Value))

【讨论】:

  • 您先生,拯救了这一天!谢谢。
【解决方案2】:

避免使用表达式的替代解决方案,在属性中将单元格格式更改为#,##0。然后更容易将其与计数或总和配对。

【讨论】:

    【解决方案3】:

    试试这个:

    =IIF(Fields!DndCount.Value=0 OR 
    IsNothing(Fields!DndCount.Value)=0 OR
    Fields!DndCount.Value="null",0,Fields!DndCount.Value)
    

    【讨论】:

      【解决方案4】:

      由于IsNothing 将返回TrueFalse 值,因此您需要将表达式设置为:

      =IIF(IsNothing(Field1) = True, 0, Field2)   
      

      希望对你有帮助。

      【讨论】:

        【解决方案5】:

        你也可以尝试使用IsMissing字段的表达式,

        像这样:

        =IIF(Fields!Accounting_Amount.IsMissing, 0, Fields!Accounting_Amount.Value)
        

        【讨论】:

          猜你喜欢
          • 2022-01-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-03-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多