{"id":54,"date":"2012-09-10T08:33:00","date_gmt":"2012-09-10T03:03:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=54"},"modified":"2012-09-10T08:33:00","modified_gmt":"2012-09-10T03:03:00","slug":"phone-formating-in-ssrs-report","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2012\/09\/phone-formating-in-ssrs-report\/","title":{"rendered":"Phone Formating in SSRS report"},"content":{"rendered":"<div dir=\"ltr\" trbidi=\"on\"><span> <\/span><\/p>\n<div><span><span>Many a times\u00a0there\u00a0had been requirements\u00a0to format the CRM phone number in the SSRS report in following format.<\/span><\/span><\/div>\n<p><span> <\/span><\/p>\n<div><a href=\"http:\/\/1.bp.blogspot.com\/-rxHwdj4BUw4\/UE2j3LCDK8I\/AAAAAAAABWA\/LryC20Jm6jw\/s1600\/Untitled.jpg\" imageanchor=\"1\"><span><img decoding=\"async\" border=\"0\" height=\"61\" src=\"http:\/\/1.bp.blogspot.com\/-rxHwdj4BUw4\/UE2j3LCDK8I\/AAAAAAAABWA\/LryC20Jm6jw\/s320\/Untitled.jpg\" width=\"320\"><\/span><\/a><\/div>\n<p><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>We tried to achieve this by creating 12 text boxes and in each textbox we applied the below logic in the expression.<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span><\/p>\n<div><b><i><span lang=\"EN-IN\"><span><span>= IIF(Fields!telephone1.Value.toString().Length>=1, GetChar(Fields!telephone1.Value.toString(),1), \u201c\u201d)<\/p>\n<p><\/span><\/span><\/span><\/i><\/b><\/div>\n<p><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>It works successfully when the length of phone number is equal to 10. But it fails when the length of phone number is less than 10\u00a0and you will get an error while running this report.<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>To resolve this issue we found\u00a0a work around for this.<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>First you need to format the data using the SQL query and PAD the spaces into the field. As given below.<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span><\/p>\n<div><b><span lang=\"EN-IN\"><em><span><span>LEFT(ISNULL(telephone1, &#8221;) + &#8216;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8216;, 10)<\/p>\n<p><\/span><\/span><\/em><\/span><\/b><\/div>\n<p><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>The above statement will format the telephone1 attribute. If the user enters errorneuos or junk data into the telephone1 field like \u201c<b>99<\/b>\u201d, then the above statement will return the value \u201c<b>99<\/b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201d, i.e. 99 + additional 8 spaces . And in the textboxes expressions you just need to write the following expressions without checking the IIF condition.<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span><br \/><span><\/p>\n<div><b><span lang=\"EN-IN\">= GetChar(Fields!telephone1.Value.toString(),1)<\/p>\n<p><\/span><\/b><\/div>\n<p><span> <\/span><\/p>\n<div><b><span lang=\"EN-IN\">= GetChar(Fields!telephone1.Value.toString(),2)<\/span><\/b><b><span lang=\"EN-IN\"><\/p>\n<p><\/span><\/b><\/div>\n<p><span> <\/span><\/p>\n<div><b><span lang=\"EN-IN\">= GetChar(Fields!telephone1.Value.toString(),3)<\/span><\/b><b><span lang=\"EN-IN\"><\/p>\n<p><\/span><\/b><\/div>\n<p><span> <\/span><\/p>\n<div><b><span lang=\"EN-IN\">= GetChar(Fields!telephone1.Value.toString(),4)<\/span><\/b><b><span lang=\"EN-IN\"><\/p>\n<p><\/span><\/b><\/div>\n<p><span>   <\/span><\/span><span lang=\"EN-IN\"><\/p>\n<p><span><\/span><\/p>\n<p><\/span><br \/><span> <\/span><\/p>\n<div><span lang=\"EN-IN\"><span><span>Hope this helps!<\/p>\n<p><\/span><\/span><\/span><\/div>\n<p><span> <\/span>\u00a0<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Many a times\u00a0there\u00a0had been requirements\u00a0to format the CRM phone number in the SSRS report in following format. We tried to achieve this by creating 12 text boxes and in each textbox we applied the below logic in the expression. = IIF(Fields!telephone1.Value.toString().Length>=1, GetChar(Fields!telephone1.Value.toString(),1), \u201c\u201d) It works successfully when the length of phone number is equal to\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2012\/09\/phone-formating-in-ssrs-report\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[19,58],"tags":[829,1306,1701],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm","category-ssrs-reports","tag-formatiing","tag-phone-number","tag-telephone1"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}