Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Get #ERROR with IIF(xxx="", "", Replace(....)) when data is null.

$
0
0

Using ssrs 2014 I have a cell in a tablix where I need to replace Chr(13) with VbCrLf to make the line breaks show.  All was good until the call received a null from the database.  I ran the select on the db to confirm it was returning null and not an empty string.

The original expression was this:

=First(Fields!Id_Rationale.Value).Replace(Chr(13),VbCrLf)

but the cell would show #ERROR when it received the null or empty value.

so then I tried this:

=IIF(Fields!Id_Rationale.Value = "", "", First(Fields!Id_Rationale.Value).Replace(Chr(13),VbCrLf))

and this:

=IIF(IsNothing(Fields!Id_Rationale.Value), "", First(Fields!Id_Rationale.Value).Replace(Chr(13),VbCrLf))

and this:

=IIF(IsNothing(Fields!Id_Rationale.Value) OR Fields!Id_Rationale.Value = "", "", First(Fields!Id_Rationale.Value).Replace(Chr(13),VbCrLf))

but if I run this I don't get the #ERROR

=IIF(Fields!Id_Rationale.Value = "", "empty string", "not empty string")

hmmm.  so I tried this

=IIF(Fields!Id_Rationale.Value = "", "empty string", First(Fields!Id_Rationale.Value).Replace(Chr(13),VbCrLf))

and got #ERROR again.

I'm puzzled. any idea how to make this work and not get #ERROR on empty values?

Thanks.


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>