Showing posts with label SSRS. Show all posts
Showing posts with label SSRS. Show all posts

Wednesday, March 11, 2015

To set multiple line in a textbox in SSRS

If we want to have multiple line in a single text box in report like below:

Name:      Address:   City:      State:    ...
Jon Doe    Addr1      ThisTown    XX       ...    
               Addr2
               Addr3
-----------------------------------------------
Jane Doe   Addr1      ThisTown    XX       ...
               Addr2
               Addr3
-----------------------------------------------

We can use the & VbCrLf & between the expression as given below which works fine. 

= Fields!Addr1.Value & VbCrLf & 
   Fields!Addr2.Value & VbCrLf &
   Fields!Addr3.Value

Friday, September 14, 2012

Using Multi-Value Parameter in SSRS via Stored Procedure


It has been found that in SSRS 2005-2012, when we use direct query as data set we are able to apply multi-value parameter and the report works when we select multiple values in parameter.

E.g., Let the direct query be as follows:

SELECT CustomerName, AccountNo, SalesAmount FROM dbo.Sales
WHERE Country in (@Country)

When we use the above query in dataset a parameter Country will be created in Parameter list, and we can configure parameter as shown below, the report work well when we select multiple values in parameter.


When the same query is executed as stored procedure, the report will fail when we select multiple values in parameter. To overcome this issue we need to create the given function in our database:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[MultiParameter]
(
   @DelimittedString [varchar](max),
   @Delimiter [varchar](1)
)
RETURNS @Table Table (Value [varchar](100))
BEGIN
   DECLARE @sTemp [varchar](max)
   SET @sTemp = ISNULL(@DelimittedString,'')
                + @Delimiter
   WHILE LEN(@sTemp) > 0
   BEGIN
      INSERT INTO @Table
      SELECT SubString(@sTemp,1,
             CharIndex(@Delimiter,@sTemp)-1)
     
      SET @sTemp = RIGHT(@sTemp,
        LEN(@sTemp)-CharIndex(@Delimiter,@sTemp))
   END
   RETURN
END
GO

And we need to modify the stored procedure as like below:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  BabukannanM
-- Create date: September 19, 2012
-- Description: To list of Customer by Countrywise
-- =============================================
CREATE PROCEDURE [dbo].[Rpt_Customer]
 @Country NVARCHAR(MAX)
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
    SELECT CustomerName, AccountNo, SalesAmount FROM dbo.Sales
  WHERE Country IN (Select * from [dbo].[MultiParameter] (@Country, ',') )

END
GO

 Now configure the report parameter to select multi-values.

How to get customized colors in SSRS chart

While we design SSRS chart, we have to use available colors from SSRS Color pallette or color templates by selecting them from color, background color, etc. Instead we can apply our own defined colors to our chart by following below steps:

Step 1: Create new SSRS report.

Step 2: Go to Report properties of the SSRS report. Open Code section and copy-paste the below code in the Code area:

Private colorPalette As String() = { "Blue", "Red", "Teal", "Gold", "Green","#A59D93", "#B8341B", "#352F26", "#F1E7D6", "#E16C56", "#CFBA9B"}

Private count As Integer = 0

Private mapping As New System.Collections.Hashtable()

Public Function GetColor(ByVal groupingValue As String) As String

If mapping.ContainsKey(groupingValue) Then

Return mapping(groupingValue)

End If

Dim c As String = colorPalette(count Mod colorPalette.Length)

count = count + 1

mapping.Add(groupingValue, c)

Return c

End Function




Step 3: Now create a chart (e.g., pie chart); Open Series properties, in Fill expression copy-paste below command:

=code.GetColor(Fields!SalesMonth.Value)


Step 4 (Option): You can use this color in your grid report as a background, by copy-paste the below code in Columns Background properties:

=code.GetColor(Fields!SalesMonth.Value)

The output will be simillar to one below:


Friday, June 1, 2012

Difference between MS SQL Server Reporting Services 2005 and 2008


SSRS 2005
SSRS 2008
Multiple service architecture (IIS Service & Windows Service)
Single service architecture (Windows Service)
Depends on IIS
Comes with Built-In Web Server and hence does not depend on IIS
Complex deployment due to the need for separate configuration for IIS
Deployment is simple due to inbuilt web server and Reporting Services Configuration Manager
Charts, Dials etc. had to be separately installed and integrated
Comes packaged with Charts, Dials, Indicators, Sparklines etc.
Limited exporting options
More exporting options including Microsoft Word etc
You can only format entire text in a textbox with one single formatting style (bold,italicize,colors,etc.)
Allows you to format pieces of text or words or letters within a single textbox with different formatting styles like bold,italicize,colors,etc. Example: a Disclaimer Textbox, Header Textbox etc.
Don't Support html data fields It has HTML capability (can read data from html data fields)
It has less visualization components It has a very rich set of visualization components like Dials, Gauges, Sparklines etc.