This isn't really a blog, its more of a holding page for my domain (seems a shame not to have a page), if I know you then add me on either LinkedIn or Facebook (links are on the right), however if I don't know you then I won't add you!

Tuesday 21 May 2013

SSRS Series - How to format addresses in SSRS


·         How to format an address block in SSRS, ideal for SSRS generated letters, invoices, bills and orders. 

·         Removes any blank address lines that the record has in your database.

·         Adds carriage returns after each populated line to give the distinctive address block appearance

There are two ways to approach msaaging/formatting fields into an address block in SSRS, you can either carry out your formatting in the SQL that populates the dataset or you can format the fields from the dataset in an SSRS expression. 

I’ve found that the easiest method is to format the address through an SSRS expression contained in the report, this keeps the SQL that populates the dataset as clear as possible and any issues associated with the expression are easily identifiable.

Example Data

·         Stored in dataset titled “DATASET”
·         The exact number/naming of fields will differ depending on your database.

MAILING_NAME
Mr J Davies
ADD1
The Whitehouse
ADD2

ADD3
Reindeer Road
ADD4

ADD5

TOWN
Reading
PCODE
NA13 6DF
COUNTRY
United Kingdom

Example expression

·         Create a new text box and add the following expression (change the name of the dataset/fields to reflect your data).

=First(Fields!MAILING_NAME.Value,”DATASET”)+IIF(First(Fields!MAILING_NAME.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!ADD1.Value,”DATASET”)+IIF(First(Fields!ADD1.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!ADD2.Value,”DATASET”)+IIF(First(Fields!ADD2.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!ADD3.Value,”DATASET”)+IIF(First(Fields!ADD3.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!ADD4.Value,”DATASET”)+IIF(First(Fields!ADD4.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!ADD5.Value,”DATASET”)+IIF(First(Fields!ADD5.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!TOWN.Value,”DATASET”)+IIF(First(Fields!TOWN.Value,”DATASET”) ="","",", "+VbCrLf)
+First(Fields!PCODE.Value,”DATASET”)+IIF(First(Fields!PCODE.Value,”DATASET”) ="","",""+VbCrLf)
+First(Fields!COUNTRY.Value,”DATASET”)

Example report view

Mr J Davies,
The Whitehouse,
Reindeer Road,
Reading,
NA13 6DF,
United Kingdom

6 comments:

  1. This is exactly what I needed, came up on the first google item search. Thank you

    ReplyDelete
  2. Thanks for sharing this great information on Oracle ADF. Actually I was looking for the same information on internet for Oracle ADF Interview Questions and Answers/Tips and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle ADF by attending Oracle ADF Training.

    ReplyDelete
  3. An error occured during locak report processing.
    The definition of the report " is invalid.
    The value expression for the textrun 'Textbox4.Paragraphs[0]' has a scope parameter that is not valid for an aggregrate function.
    The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing region, or the name of a dataset.

    I am having the above error when i attempt this, can someone assist?

    ReplyDelete

  4. An error occured during locak report processing.
    The definition of the report " is invalid.
    The value expression for the textrun 'Textbox4.Paragraphs[0]' has a scope parameter that is not valid for an aggregrate function.
    The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing region, or the name of a dataset.

    I am having the above error when i attempt this, can someone assist?

    ReplyDelete
  5. Amazing find, this is exactly what i needed and it was very first link from google search .. thank you so much!

    ReplyDelete