Formatting Phone Numbers in SQL Reporting Services

Every time, without fail, I need to create a phone number on an SSRS report for a client and get stuck with phone formatting. Every time I am searching forums. I thought it would be awesome if it was in some amazing blog that I could visit and copy from each time.

So... here it is, if not for myself, then for others:

In Report Builder or visual studio, add your phone number field to the report. 

Right click on that text box where you added the field and click on expression. 

Clear the formula box and type in the expression below.



Formula to Use: 
=IIF(Fields!Phone.Value Is Nothing, Nothing, IIF(IsNumeric(Fields!Phone.Value), Format(Val(Fields!Phone.Value), "(000) 000-0000"), Fields!Phone.Value))














Note: My field is actually called Phone. If your field is not called phone, you will need to replace it with your phone field name. (Like: Fields!E_T_PHONE_HOME.Value)


Then click on OK at the bottom of the expression box.

Run your report.








Magic...
Until next time.

Comments

  1. Replies
    1. Download and install gta game free from https://gtavicecityapk.com/ and enjoy the unlimited fun.

      Delete
  2. The most important aspect of choosing the right cursive text generator for a project is the format. Most font providers offer several formats including TrueType, OpenType, PostScript and their variations.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I'm getting a scope issue when I try to use this formula within a group setting (vendor info in a "row outside the group" and part info as the lines of the group). It will do a single iif, it will do the format, but it seems like Phone loses its scope when I use the iif within an iif, I didn't try the format inside one iif). Any thoughts as to why? TiA!

    ReplyDelete

Post a Comment