Archive for the 'Reporting Services' Category

Dynamic Report Formatting

Monday, July 23rd, 2007

Formatting your report based on the user or the data is relatively straight forward once you get the trick. To demonstrate, create a report with a valid connection to an instance of Microsoft SQL Server and use the following SQL as your query:

SELECT
    CASE @param
        WHEN 0 THEN 'Blue'
        WHEN 1 THEN 'Red'
    END AS color,
    CASE @param
        WHEN 0 THEN '12pt'
        WHEN 1 THEN '24pt'
    END AS size

and create five text boxes with the following attributes:
TextBox1
Value: Color
Color: =First(Fields!color.Value)

TextBox2
Value: Size
Font: Normal, Arial, =First(Fields!size.Value), Normal

TextBox3
Value: Both
Color: =First(Fields!color.Value)
Font: Normal, Arial, =First(Fields!size.Value), Normal

TextBox4
Value: =First(Fields!color.Value)

TextBox5
Value: =First(Fields!size.Value)

and then run the report. When you run your report you should see something like the following: