I am creating a report using SSRS for a phone number field in my database as a string value. I need to format a string value in phone number format (555) 555-1212. If the value is null, display nothing.
For example, a table in my database has a phone number column and some values are NULL.
I got a regex that formats the phone number fine.
=System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value, "(\d{3})[ -.](\d{3})[ -.](\d{4})","($1) $2-$3")
However if I do this:
=IIf(Fields!Phone.Value is nothing, "", System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value,"(\d{3})[ -.](\d{3})[ -.](\d{4})","($1) $2-$3"))
Then it comes back with an error. #ERROR is displayed on my report. Can you use iif with a regex? Is there another way?