Search code examples
crystal-reportsreportstring-formattingphone-number

Crystal Reports formula to add formatting if the string is not null?


I have a secondary phone number that is not always filled out but must still appear on a report. I'm trying to make a simple formula that tests if the string is null and if not add formatting to a phone number.

I can add formatting to the phone number by using:

picture ({table1.PhoneNumber},"(xxx)xxx-xxxx")

And I know there is an "IsNull" operator but I can't really figure out the syntax to put the two statements together.

I need to do this:

If the phone number is not null then apply formatting, If it is null then make the string = "N/A"


Solution

  • if isnull({table1.PhoneNumber}) then
     'N/A'
    else
     picture ({table1.PhoneNumber},"(xxx)xxx-xxxx")