SSRS expression replace NULL with another field value

后端 未结 2 933
南旧
南旧 2020-12-08 06:44

I need to write an SSRS expression to check and replace NULL field value with another field value. Can this be done?

相关标签:
2条回答
  • 2020-12-08 07:04
    =iif(isNothing(Fields!FV1.Value), Fields!FV2.Value, Fields!FV1.Value)
    
    0 讨论(0)
  • 2020-12-08 07:13

    If you have to do it a bunch of times, you can also make a reusable function to avoid a lot of typing. Here's a solution modeled off of SQL's ISNULL function:

    1. Right click on the Report Document and go to Report Properties.

    2. Navigate to the Code tab and add the following function:

      Public Function IsNull(input As Object, defaultValue As Object) As Object
        Return IIf(input Is Nothing, defaultValue, input)
      End Function
      

      Note - Even though the custom code is expecting valid VB.NET code, you have to use the IIF Ternary operator.

    3. Then you can use it in an expression like this:

      =Code.IsNull(Fields!MyField.Value,0)
      

    0 讨论(0)
提交回复
热议问题