You are on page 1of 58

Rama Rao

SQL SERVER REPORTING SERVICES-2012


SSRS Architecture
Reporting Services architecture includes development tools, administration tools, and report viewers.
There are a number of ways to get to Reporting Services programmatically, including URL, SOAP and
WMI interfaces.

Report Server: - Report Server is the core engine that drives Reporting Services. The URL for Report
server is, http://servername/reportserver
Report Manager: - Report Manager is a Web-based administrative interface for Reporting Services.
The URL for Report Manager is, http://servername/reports
Note: - The content of Report Server is same as Report Manager.
Report Designer: - Report Designer is a developer tool for building complex reports. Report Designer
can create reports of any complexity that Reporting Services supports, but requires you to understand
the structure of your data and to be able to navigate the Visual Studio user interface (Business
Intelligence Development Studio).
Report Builder: - Report Builder provides a simpler user interface for creating ad hoc reports,
directed primarily at business users rather than developers. Report Builder requires a developer or
administrator to set up a data model (.smdl) before end users can create reports.

Designing a Report from Report Designer:


Step to Create a new Report:
1.

Open Business Intelligence Development Studio (BIDS)

Page
1

Rama Rao
2.

Select File New Project.

3.

Select the Business Intelligence Projects project type.

4.

Select the Report Server Project template.

5.

Name the new report MorningBatch and pick a convenient location to save it in.

6.

Right-click on the Reports node in Solution Explorer (Ctrl+Alt+l) and select Add New
Item.

7.

Select the Report template.

8.

Name the new report Tabular.rdl and click Add.

9.

In the Report Data (Ctrl+Alt+d) window, select New Data Source.

10. In Shared Data Source Properties Editor,


a.

NameDSrcProductDetails

b.

TypeSelect Microsoft SQL Server (default)

c.

Click Edit

d.

In Connection Properties editor, Provide,


i.

Server Name localhost or . or servername

ii.

Connect to Database Select AdventureWorks database from dropdownlist

iii.

Click Ok

11. Click Ok
12. In the Report Data window, select DSrcProductInformation Right and select Add
Dataset.
13. In Dataset Properties Editor, Provide the following information,
a.

Name dsProducts

b.

DataSource Select DSrcProductInformation

c.

Query Type Select or Check Text Radio Button to the dataset from SQL Script

d.

Query Click Query Designer to build the query or build the query on SQL Server
Management Studio,

e.

In Query Designer , Click Edit As Text

f.

Click Add Tables to add tables to query list

g.

Production.Product, Production.ProductSubcategory and


Production.ProductCategory tables

h.

Select the following columns or fields from the above mentioned tables,

Page
2

Rama Rao
Production.ProductCategory.ProductCategoryID, Production.ProductCategory.Name AS
CategoryName, Production.ProductSubcategory.ProductSubcategoryID,
Production.ProductSubcategory.Name AS SubcategoryName,
Production.Product.ProductID, Production.Product.Name, Production.Product.Color,
Production.Product.ReorderPoint, Production.Product.StandardCost,
Production.Product.ListPrice, Production.Product.Size, Production.Product.Weight,
Production.Product.Class, Production.Product.Style, Production.Product.SellStartDate
i.
j.

Click Ok
Finally, the dataset (dsProducts) query is generated as mentioned below,
SELECT
Production.ProductCategory.ProductCategoryID,
Production.ProductCategory.Name AS CategoryName,
Production.ProductSubcategory.ProductSubcategoryID,
Production.ProductSubcategory.Name AS SubcategoryName,
Production.Product.ProductID, Production.Product.Name, Production.Product.Color,
Production.Product.ReorderPoint, Production.Product.StandardCost,
Production.Product.ListPrice, Production.Product.Size, Production.Product.Weight,
Production.Product.Class, Production.Product.Style, Production.Product.SellStartDate
FROM
Production.Product INNER JOIN
Production.ProductSubcategory ON
Production.Product.ProductSubcategoryID =
Production.ProductSubcategory.ProductSubcategoryID INNER JOIN
Production.ProductCategory ON Production.ProductSubcategory.ProductCategoryID =
Production.ProductCategory.ProductCategoryID

14. Click Refresh fields and Click Ok. Finally, the datasource and dataset looks like,

Page
3

Rama Rao

15. Open the Toolbox window (View Toolbox or Ctrl+Alt+x).


16. Double-click the Table Report Item.
17. Switch back to the Report Data window.
18. Expand the dataset to show the column names.
19. Drag the CategoryName field and drop it in the first column of the table Report Item on
the design tab. And, follow the same process for other fields to be mapped or bind the table
report item.
20 Finally, the SSRS Report Design looks like,

Page
4

Rama Rao

20. Select the Preview tab to see the report with data.

Page
5

Rama Rao

Parameterized Reports
parameterized report uses input values to complete report or data processing. With a
parameterized report, you can vary the output of a report based on values that are set when the
report runs. Parameterized reports are frequently used for drill-through reports, linked reports,
and sub-reports, connecting and filtering reports with related data.
A

Steps to Configure Parameterized Reports:


1.

In our previous/above mentioned dataset (dsProducts), add the following where clause at
the end of the query,

WHERE

Production.ProductCategory.ProductCategoryID = @ProductCategoryID

Note:- Here, @ProductCategoryID is a parameter


2.
3.

4.

In the Report Data window, select DSrcProductInformation Right and select Add
Dataset.
In Dataset Properties Editor, Provide the following information,
a.

Name dsProductCategoryIDName

b.

DataSource Select DSrcProductInformation

c.

Query Type Select or Check Text Radio Button to the dataset from SQL Script

d.

Query Click Query Designer to build the query or build the query on SQL Server
Management Studio,

Provide the following query to build the dataset for CategoryID and Name
SELECT
FROM

5.
6.

ProductCategoryID, Name AS CategoryName


Production.ProductCategory

Click Refresh Fields and Click ok to save the changes.


In the Report Data window, Expand Parameters Double Click on ProductCategoryID

parameter
In Report Parameter Properties Editor,
Select Available Values Check Get Values from Query Radio
button
8. And, Set, DatasetSelect dsProductCategoryIDName
7.

Value Field Select ProductCategoryID (Values field must be same as


parameter name)

Page
6

Rama Rao

Multi-valued Parameterized Reports:


From the above designed report, set the following properties to design multivalved parameterized
report.
In multi-valued parameterized reports, the user can select more than 2 parameter or show all values
from dropdown list.

Steps to configure Multi-valued Parameterized report:


1.

In our previous/above mentioned dataset (dsProducts), add the following where clause at
the end of the query,

WHERE Production.ProductCategory.ProductCategoryID IN
(@ProductCategoryID))
Note:- Here, @ProductCategoryID is a parameter
2.
3.

In the Report Data window, Expand Parameters Select ProductCategoryID Right and
select Parameter Properties option.
In Report Parameters Wizard, set the following setting,
In General Page, Check Allow multiple Values check box

4.
5.

Click Ok to save the changes


Preview Report.

Chart Report:
Chart report is used to display the to present data graphically as bars, pies, column and other
chart types

Steps to Configure Chart


In our previous report example, Add Chart Report item from Toolbox, Select Column chart and click
Ok.
1.

Select Chart and Right Click and select Chart Properties

2.

In General page, Dataset Select dsProduct and click Ok

3.

Click on Chart Area

4.

Go Report Data window

Page
7

Rama Rao
5.

Expand dsProduct Drag and drop standardcost field on Data (Y-Axis)

6.

Drag and drop SellStartDate field on Category section (X-Axis)

7.

Select SellStartDate field from Category section Right Click Select Category Group
Properties

8.

In Category Group Properties Editor,


Label Click fx Provide the following expression to display SellStartDate in the below
format (Jun-01),

=Left(MonthName(Month(Fields!SellStartDate.Value)),3) &"-"&
Right(Year(Fields!SellStartDate.Value),2)
9.

Click Ok

How to display Label on Series


1.

In the above mentioned column report, Select Series Right Click and Select Show Data
Labels option

Page
8

Rama Rao

How to set Custom Color to the Chart Series (Data)


1.

In the above mentioned column report, Select Series Right Click and Select Series
Properties option

2.

In Series Properties Editor, Select Fill page

3.

Color Select any Color from colors list.

4.

Click Ok

And, also try out other properties like,


1.
2.
3.

Legend
Major and Minor Tick Lines
Scale Properties and etc.

Rectangle
Rectangle report item is a container for other report items. If we set any property to this rectangle
container, then that applicable to all the report items on it.
Note:- Rectangle can be placed either in Header or Footer Section of the report.

Steps to Configure Rectangle


1.

In our previous/above report example, Add/drag and drop Rectangle Report Item

Page
9

Rama Rao
2.

Select the Rectangle Right Click Select Rectangle Properties

3.

In Rectangle Properties Editor, Name RectTable Click Ok

4.

Drag and drop the already Designed Table report on RectTable named rectangle

5.

Add/drag and drop another Rectangle Report Item

6.

Select the Rectangle Right Click Select Rectangle Properties

7.

In Rectangle Properties Editor, Name RectChart Click Ok

8.

Drag and drop the already Designed Chart report on RectChart named rectangle

Scenario: - Display table report (First report) item in Sheet 1/Page 1 and Chart report
item (Second Report) in Sheet 2/Page 2, when we export it excel or PDF.

1.

Select RectTable rectangle Right click Select Rectangle Properties

2.

And, Check Add a Page Break After Checkbox. In order to maintain page breaks
between recttable and rectchar rectangles

3.

Preview the report Export the report to Excel

4.

Sheet I Table Report will be displayed

5.

Sheet 2 Chart report data will be displayed.

Image Report Item:


Image report item is used to display a bit mapped images such as photos or logos in a
report. The Selected or configured image will be part of the report.

Scenario: -Display company logo on each and every page.


Steps to Configure Image Report Item: 1. In Business Intelligence Development Studio (BIDS)
2. Select Report Menu Select Add Page Header (to display the embedded logo on
every page of report)
3. Select Toolbox Drag and drop Image report item on Page Header Section of the report
4. In General Page Click Image button to import a bit mapped image

Page
10

Rama Rao
a.

Navigate to the path where the logo files located

b.

Select any file from the list and click Open

5. In Action Page Check Go to URL radio button Provide the follow URL,
http://www.vijayit.com

6. Click Ok

Text Box: Text box report is used to display labels or fields or values from expressions.
Scenario: - Display Page numbers in each and every page of the report in the following format, Page
1 of 10.

Steps to configure Text box report Item:


1.

In the above designed report example, Select Report Select Add Page Footer to add footer
of page.

2.

In Tool Box Drag and drop Text box on Page Footer section

3.

Select Textbox Right Click and select Expression

4.

Provide the following expression to display page numbers dynamically,


="Page "&Globals!PageNumber & " of "&Globals!TotalPages

5.

Click ok

List Report Item:- List report item is used to display a set of report items that are repeated for
each group or row of data.

Steps to Configure List Report Item


1.

In the above mentioned report item remove Add Page Break at End option for the
RectTable rectangle and keep multi-value option as it is.

2.

Select List Report Right Click Select Tablix Properties (List)

3.

In Tablix Properties Editor Dataset name Select dsProduct dataset.

4.

Click Ok

5.

Select Tablix Row Right click Select Row Group Select Group Properties

6.

In Group Properties Editor Click Add to a new group And Select,


Group on Select Color or Category

Page
11

Rama Rao

7.

Click Ok

8.

Place the report items that you would like to repeat for each and every group on above
configured list report.

9.

Preview Report

Groups Or Drilldown reports: Drilldown reports initially hide complexity and enable the user to toggle
conditionally hidden report items to control how much detail data they want to see. Best example of
Drilldown report is Sale information for the Year, then drill down for Quarters followed by Months and week.
Other example is Sale by Region then drilldown by Countries followed by State and Cities.
In Report Designer (BIDS), Groups are created to organize data on the report or to calculate aggregate summaries.
An understanding how to define groups and use group features helps you design reports that are more concise and
communicate summarized data in a more compact format.
We also use Groups in SSRS reports to provide Drill-down features.

Steps to Configure Grouped or Drilldown Reports

1.

Open BIDS and Create a new report Rename it as DrilldownReport.rdl

Page
12

Rama Rao
2.
3.

Create new Shared DataSource for database AdventureWorksDW2008R2.


Create a new dataset dsMain with Shared Data Source. Use below query for this dataset:
SELECT
D.CalendarYear AS [Year]
,D.CalendarQuarter AS [Quarter]
,D.EnglishMonthName AS [Month]
,D.FullDateAlternateKey AS [Date]
,P.EnglishProductName AS [ProductName]
,C.FirstName + LastName AS [CustomerName]
,ST.SalesTerritoryRegion AS [SalesRegion]
,ST.SalesTerritoryCountry AS [SalesCountry]
,F.SalesOrderNumber AS [OrderNumber]
,F.SalesAmount
FROM FactInternetSales F
JOIN DimProduct P
ON P.ProductKey = F.ProductKey
JOIN DimCustomer C
ON C.CustomerKey = F.CustomerKey
JOIN DimDate D
ON D.DateKey = F.OrderDateKey
JOIN DimSalesTerritory ST
ON ST.SalesTerritoryKey = F.SalesTerritoryKey

4.

Drag and drop a table control and select CustomerName, OrderNumber, and SalesAmount fields in the
table.

5. Select table detail row --> Right click --> select Add Group --> Row Group --> Parent Group

Page
13

Rama Rao

6. Select ProductName in Tablix group window and check add group header check box. Click OK and sace
changes.

Now you can see Product Group in the table as shown below:

Delete Group1 Column and rename Customer Name as Particulars. Select ProductName in Product Group as
shown below:

7. Select ProductName group and add one more group for SalesCountry in similar way mentioned at step5. Delete
the group column and select SalesCountry in CountryGroup as shown below:

Page
14

Rama Rao

8. In the same way add Groups for the following Fields:

SalesRegion
Date

Month

Quarter

Year

Finally table will look like one shown in below image:

9. We are done with report Groups. You can Preview the report:

10. Format Groups: This is the final step. Without formatting the tabular data look meaningless and its very
difficult to understand the report. You can do following formatting to make it easier to understand:

Group

Left Indent BackgroundColor

Year

2pt

#7c73c8

Quarter

12pt

#9894ca

Month

22pt

#b4b4c8

Date

32pt

#c7c7d8

Page
15

Rama Rao

SalesRegion

42pt

#dadaeb

SalesCountry

52pt

#e7e7f0

ProductName

62pt

#f4f4fc

CustomerName
72pt
(detail row)

White

Toggle Groups:
Select Quarter Group and click on Group Properties. Select Visibility in Group Properties and select Hide option
button. Check Dispaly can be toggled by this report item check box and select Year from combo box.

Similar way toggles other report items.


Also Toggle Order Number column with Particular text box.
Now click on Preview and generate the report:

Page
16

Rama Rao

Drill-through Report
Drillthrough reports are standard reports that are accessed through a hyperlink on a report item in the
original report. Drillthrough reports work with a main report and are the target of a drillthrough action
for a report item such as placeholder text or a chart. The main report displays summary information,
for example in a matrix or chart. Actions defined in the matrix or chart provide drillthrough links to
reports that display greater details based on the aggregate in the main report. Drillthrough reports
can be filtered by parameters.

Steps to configure Drillthrough report:


1.
2.

Open Business Intelligence Development Studio (BIDS)


Select File New Project.

3.

Select the Business Intelligence Projects project type.

4.

Select the Report Server Project template.

5.

Name the new report DrillThrough_SalesOrder and pick a convenient location to save it in.

6.

Right-click on the Reports node in Solution Explorer (Ctrl+Alt+l) and select Add New
Item.

7.

Select the Report template.

8.

Name the new report SalesOrder.rdl and click Add.

9.

In the Report Data (Ctrl+Alt+d) window, select New Data Source.

10. In Data Source Properties Editor,

Page
17

Rama Rao
a.

NameDSrcSalesOrdersPerProduct

b.

TypeSelect Microsoft SQL Server (default)

c.

Click Edit

d.

In Connection Properties editor, Provide,


i.

Server Name localhost or . or servername

ii.

Connect to Database Select AdventureWorks database from dropdownlist

iii.

Click Ok

11. Click Ok
12. In the Report Data window, select DSrcSalesOrdersPerProduct Right and select Add
Dataset.
13. In Dataset Properties Editor, Provide the following information,

a.

Name dsSalesOrderDetails

b.

DataSource Select DSrcSalesOrdersPerProduct

c.

Query Type Select or Check Text Radio Button to the dataset from SQL Script

d.

Query Click Query Designer to build the query or build the query on SQL Server
Management Studio,

e.

In Query, Provide the following query to design dataset,

SELECT
FROM
WHERE
14.

Click Ok

SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber,


OrderQty, ProductID, SpecialOfferID, UnitPrice,
UnitPriceDiscount, LineTotal, rowguid, ModifiedDate
Sales.SalesOrderDetail
(ProductID = @ProductID)

15.
16.
17.
18.
19.

Open the Toolbox window (View Toolbox or Ctrl+Alt+x).


Double-click the Table Report Item.
Switch back to the Report Data window.
Expand the dataset to show the column names.
Drag the required fields and drop it in the first column of the table Report Item on the design
tab.
20. Finally, Preview the Report
21. In Preview Tab, Provide any ProductID and Click View Report.

Design Parent/Master/Summarized/Drill through Report

Page
18

Rama Rao

Drillthrough reports: Drillthrough reports are standard reports that are accessed through a
hyperlink on a report item in the original report. Drillthrough reports work with a main report and are
the target of a drill through action for a report item such as placeholder text or a chart. The main
report displays summary information. Drillthrough reports can be filtered by parameters.
1.

Open BIDS

2.

Create a new report and rename it as Summerized Report.rdl

3.

Create a new dataset and rename it as dsProductSubCategory and provide the following
query,
Select c.ProductCategoryID,c.Name as Category,
COUNT(sc.ProductCategoryID) as NoOfSubCategory
from Production.ProductCategory c
inner join Production.ProductSubcategory sc on
sc.ProductCategoryID=c.ProductCategoryID
group by c.ProductCategoryID,c.Name
and Click Apply and Ok

4.

From Toolbox, drag and drop chart report item on to design area, and select Pie chart
report, And set dsProductSubCategory and click ok.
Add =Sum(Fields!NoOfSubCategory.Value)expression on Data Section
And, also add =Fields!Category.Value expression on Series section (at right hand

side)

Page
19

Rama Rao
5.

Click on any Series Right Click Select Show Data Labels option

6.

Select Series Right Click Select Series Properties options Labels


Click fx (expression) button and provide the following expression to display the series label in
Category (NoofSubCategories) Ex: Bikes(3)
=Fields!Category.Value & " (" & Sum(Fields!NoOfSubCategory.Value) & ")"

Steps to configure Detailed report


1.

Open BIDS and Add a new report item and rename it as DetailedReport.rdl

2.

Create a new data source

3.

Create a new dataset from the above mentioned data source

4.

Add the below query in dataset,

select
sc.ProductCategoryID
,sc.ProductSubcategoryID
,sc.Name
,sc.ModifiedDate
from
Production.ProductSubcategory sc
where sc.ProductCategoryID=@ProductCategoryID
5.

Drag and drop Table report item onto report design area, and bind the
fields from dataset to table report item. And, also apply cosmetics
(like set font size, type etc)

6.

From the above screenshot, # expression represents, sequence numbers or


serial number
=RowNumber(nothing)

Page
20

Rama Rao

How to make a connection between summerized and detailed report:


1. Select pie chart report (summerized report) and right click
on series select Series Label Properties
2. Select Action Page,
3. Select Detailed Report from drop down list
4. Click Add to add the parameters,
5. Set Name ProductCategoryID
6. Set Value =Fields!ProductCategoryID.Value
7. Click Ok

Page
21

Rama Rao

Cascading Report
Dependency of parameters that means one parameter depends on another parameter.
Steps to Configure Cascading Report
1.

Create a new Report and rename it as Cascading Report.rdl,

2.

Create a new Data Source (Connection String)

3.

Create a Dataset and rename it as dsCountry

a. select CountryRegionCode, Name as Country from Person.CountryRegion


4.

Create a Dataset and rename it as dsState

a. select StateProvinceID, Name as [State] from Person.StateProvince


Where CountryRegionCode = @CountryRegionCode
5.

Create a new Dataset and rename it as dsAddress

SELECT

Page
22

Rama Rao
c.Name as Country
,s.Name as [State]
,a.AddressID,
case
when a.AddressLine1 IS null then a.AddressLine2
when a.AddressLine2 IS NULL then a.AddressLine1
else a.AddressLine1 + ', '+ a.AddressLine2 END as [Address]
,a.City,a.PostalCode
from Person.[Address] a WITH (NOLOCK)
Inner Join Person.StateProvince s WITH (NOLOCK) ON s.StateProvinceID
= a.StateProvinceID
Inner Join Person.CountryRegion c WITH (NOLOCK) ON
c.CountryRegionCode = s.CountryRegionCode
where a.StateProvinceID = @StateProvinceID

6.

Double Click on CountryRegionCode parameter, and set the following properties,

7.

In General page, Set the following optional/mandatory properties,

Page
23

Rama Rao

8.

In Available Values page, set the following optional/mandatory properties and click Ok

9.

Double Click on StateProvinceID parameter, and set the properties same as above.

Page
24

Rama Rao

10. In Design tab, Design the report layout and Preview the report.

Path for Template Report

C:\Program
Files
(x86)\Microsoft
Visual
9.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

Studio

Steps to Create a New Subscription (in Report Manager):


Subscription:
A report subscription is a report snapshot generated on some defined scheduled
time and delivered to the intended audience by the report server.
SSRS has provided two delivery extensions out of the box; the first one lets SSRS
save the report subscription to a file share location whereas the second one sends
the report in email to the specified recipients.
I am going to explore standard subscription in detail; for data driven subscription, refer to
my next article.

Page
25

Rama Rao

Getting started with Report Subscription (SSRS 2008 R2)


To setup subscription for a report, go to Report Manager, navigate to the folder that contains
the report, point to the report for which you want to set up a subscription, click on the down
arrow and click on the Manage menu item as shown below:

On the Report Properties window, click on Subscriptions on the top. This will show you two
options; the first option (New Subscription) lets you create a standard subscription for the
report whereas the second option (New Data-driven Subscription) lets you create a datadriven subscription. I will be talking more about data-driven subscriptions in my next
article.
When you click on the New Subscription link on the page shown above, it will bring up a
page with two parts. In the first part you can define the report delivery method and in the
second part you can specify subscription processing options. The Report Delivery Options
section will change depending on the delivery method you choose. For example as you can
see below, I have chosen a delivery method of E-Mail and hence it has options to specify TO,
CC, BCC, subject line, whether to include the report as link or as an attachment, etc.

Page
26

Rama Rao

If you change the delivery method to Windows File Share, the fields on screen will
change to let you specify the file name, share location, credential to use to copy the file at
that location, overwrite options, etc.

Page
27

Rama Rao
The second part of the screen lets you define the subscription processing options. Broadly
speaking, you can specify two settings here. First you define a schedule for the subscription
to process and second you specify the parameter values to be used during processing of the
reports. Here you can specify to use the default value for a parameter if it has been defined
or you can specify a new value. Please note, if you have set report snapshot for your report,
you can also specify subscription to run from the snapshot whenever the snapshot is
refreshed instead of using a schedule to process the report subscription. Also in this case
parameter values from snapshot will be used and you cannot change it.

When defining a schedule for subscription processing, you can choose to use any predefined
shared schedule (select one from the combo box) or you can use an embedded/dedicated
schedule for this subscription processing. When you click on the Select Schedule button on

Page
28

Rama Rao
the above screen, it will bring up a screen as shown below where you can define a schedule
for daily, weekly, monthly, yearly processing, etc.

Once created, you can view the subscription and its execution details in the subscription
detail page as shown below. You can click on the Edit hyperlink to modify the subscription
or select a subscription and click on the Delete button to delete it.

Page
29

Rama Rao

Report server will generate a report for each enabled subscription on the defined schedule,
for example, in my subscription I have specified file share as the delivery method and
subscription to run every 2 minutes. The result you can see below; notice that each report
has been generated every two minutes.

As I said before, the subscription detail page displays the execution details of the
subscription; notice the Last Run and Status columns below:

There are a couple of points that you need to be aware of when creating subscription for the
reports.

Page
30

Rama Rao

Steps to Repeat Table Header in Each Page:


1. Design a table report and set the following properties,
2. In Group windows, in columns groups section Click Arrow mark and select Advanced
Mode

3. Once we select Advanced Mode, Select Static group in Row Groups section and press F4 for
properties, and set the following properties,

a. Keep with Group After


b. Report On New Page True
c.

In Tablix Properties windows Row Headers Check Repear Head on


each Page

Steps to display sheet names when we export report to excel


(from SSRS 2012 only):

Page
31

Rama Rao

Open SQL Server Data Tool Design a table report Select


table report and press F4 for properties And Set the
following option,
PageName Expression =Fields!Category.Value

Creating a Map Report in SSRS - SQL Server 2012


SQL Server 2008 R2/2012 brought several new features into the SSRS (SQL Server
Reporting Services) arena. In the data visualization category, we now have three additional
ways to display and visualize/analyze data in the reports:

Sparkline and data bars Sparkline and data bars are normally used inside tables
and matrices to analyze the trend and series and compare them with each other.
Indicators If you are aware of KPIs, the concept of indicators is not new to you.
As the name implies, indicators have icons to represent trends (up, down or flat),
progress state, conditions.
Maps It allows you to create maps or maps layers to let you visualize data against
a geographic background.

Understanding Map Reports:


Example # 1:
With SSRS 2008R2 you have the capability of adding maps to your reports using spatial
data. In this tip I'll show you how to accomplish this.
If you have a table with addresses, zip codes, etc. we'll need to find the latitude and
longitude of each address.
Open SSDT (SQL Server Data Tool) and create a new project by going to File, New Project.
Under Visual Studio installed templates choose Report Server Project and choose a Name
and Location for your project.
After clicking OK, the Report Wizard will appear. Click Next at the main screen and then
you'll need to configure the data source. Since my table was created on SQL2008, I will use
this server and the database DBReports as my data source. To configure, choose Edit... and
fill in the connection properties and click Test Connection. Once the connection is successful
click OK. Rename the data source and click Next.

Page
32

Rama Rao
On the design query screen use the following query and click Next:
select
c.Name as Country
,s.Name as State
,a.City,a.PostalCode
,a.SpatialLocation AS Coordinates
from [Person].[Address] a
Inner JOin Person.StateProvince s ON a.StateProvinceID = s.StateProvinceID
Inner Join Person.CountryRegion c ON c.CountryRegionCode = s.CountryRegionCode
where s.Name = 'Alabama'
GO

In the toolbox, click the Map icon and click anywhere on the report design screen and the
New Map Layer box should appear.

Page
33

Rama Rao
In the Map Layer Box there are a few options including Map gallery, ESRI shapefile, or SQL
Server spatial query. The first layer we'll create will be the basic map layer. I'll choose Map
gallery and drilldown states by county and select Alabama.

Click Next where it will display the state of Alabama and it's outlined counties. Here you can
add a Bing Map layer if needed and select a Map resolution. Click Next.

Page
34

Rama Rao

The next screen will display map visualizations. Here you can select Basic Map, Color
Analytical Map, or Bubble Map. For this example, I'll choose Basic Map.
Next screen will let you choose a theme, single color map, and give you the option to
display labels such as county names. Once you are finished customizing your map click
Finish.
Next I usually click on the map and scale it to the size I want for display and change the
Map Title at the top to an appropriate title.

Page
35

Rama Rao

Once you have the map the way you want it you will need to add another layer for the zip
codes. To do this right click on the map and select Add Layer. Our New Map Layer box
should appear again. This time we'll choose SQL Server spatial query and click Next.

Choose the existing dataset and click Next

Page
36

Rama Rao

Here you will you see your pinpoints that were specified in the database table. You can also
change the layer type if needed. Click Next to choose a map visualization.

Once on the map visualization screen you can choose a Basic MarkerMap, Bubble Map, or
Analytical Map. For this example I'll choose Basic Marker Map because I just want to mark
my zip codes.

Page
37

Rama Rao

The next screen will allow you to choose a Theme, Marker, specify a single/multicolor map
and display labels based on your dataset. I'll choose Generic Theme, PushPin marker, and
display labels based on City. Click Finish.

Once back, you will be in design view, click Preview to preview the report.

Page
38

Rama Rao

Once you're map is the way you like it, right click the .rdl in Solution Explorer and Deploy.

Example # 2:
A map report can be layered where each layer will display a layer of geographical
background.
The types of map layers that can be added to a map report are as follows:

Polygon represents geographic areas such as countries, states, or cities,


etc.
Line represents paths and routes

Point represent locations such as stores, cities, or place

Tile represents Microsoft Bing maps tiles in map report background

Page
39

Rama Rao

Steps to Creating Map Reports:


If you want to analyze your data against a geographical background, the first thing
that you need to do is to get the geographical data or spatial information. There are
three sources:

Map Gallery There are some in built reports with map elements, which
you can use as source for spatial information but this is limited to USA
states only as of now.
ESRI shapefiles Environmental Systems Research Institute, Inc. provides
shapefiles, which can be used as source for geographical data or spatial
information.
SQL Server Spatial Data If you have geographical data or spatial
information already stored in SQL Server, you can use it directly. In the next
article, I will demonstrate how you can export ESRI shapefiles to SQL Server
and then use it from SQL Server.

To add a map to your report, drag the Map report item from the Toolbox to the
designer area:
When you drag a Map report item from the Toolbox to the designer area, a wizard
will be launched to specify the map layer detail for the map. On the first page of the
New Map Layer wizard, you need to specify the source for the spatial/geographical
data that contains set of coordinates that define the map areas. As discussed
above, there are three options here, the first Map Gallery is very limited so I will
choose the ESRI Shapefile option for this demonstration, and in the next article on
map report with drilldown I will explore the third option of getting spatial data from
SQL Server query:

Page
40

Rama Rao

Choose a source of spatial data


On the next screen of the wizard, we need to specify the map viewing options, such
as map resolution (for example high resolution brings the high quality but is heavy
weight in terms of performance), adding a Microsoft Bing Map Layer to the map,
etc., as shown below:

Page
41

Rama Rao

Choose spatial data and map view options


On the next page of the wizard, you can specify the map visualization option from
the available options (it varies from the type of map layer you chose though and
you will have a different screen if you choose a map layer other than Polygon):

Page
42

Rama Rao

Choose map visualization


On the next page of the wizard, you can specify the color theme and data
visualization option as shown below. There are already some inbuilt themes, which
you can choose or customize your map later as and when needed:

Page
43

Rama Rao

Now if you have already data source and data set added to your report, the wizard
will ask you to specify the source for the analytical data. In my case I hadn't
already, created a data source and data set, so I created it now. Then, to specify
the analytical data source for the map layer I need to select the map; from the Map
Layer window I need to select the map layer for which I need to specify the
layer/analytical data and click on the tiny icon on the right most side as shown
below. Then I need to click on Layer Data from the menu bar:

Page
44

Rama Rao

Click on Layer Data from the menu bar


The Layer Data (Map Layer Properties) dialog box appears with different pages. The
General page will display the spatial data source information with columns and let
you change it if you want to:

Page
45

Rama Rao

Change layer and spatial data source options


Click on the Analytical Data page as shown below and specify the source for the
data that you want to visualize in the map. Select the data set and add the
mapping/relationship of the columns from the spatial data set with the analytical
data as shown below:

Page
46

Rama Rao

Select fields to match spatial and analytical data


I want to analyze data from AdventureWorks2008 and used the following query:
SELECT SP.CountryRegionCode AS CountryRegionCode, SUM(SOH.SubTotal) Amount
FROM Sales.SalesOrderHeader SOH
INNER JOIN Person.Address A ON SOH.BillToAddressID = A.AddressID
INNER JOIN Person.StateProvince SP ON A.StateProvinceID = SP.StateProvinceID
INNER JOIN Sales.SalesTerritory ST ON SP.CountryRegionCode = ST.CountryRegionCode
GROUP BY SP.CountryRegionCode

Page
47

Rama Rao

Query results
Thats all, now you can preview the report; you can also change some properties
like label and tooltip, as shown below, to make it look more intuitive:

World wide sales map report


During the preview, I was getting a message that the "number of map point
elements exceeds the maximum limit for the map. The remaining points
do not appear in the map" and map was not being rendered properly. I increased
the values for MaximumTotalPointCount and the
MaximumSpatialElementCount property slightly and it worked; refer to this
link orthis link for more details on the resolution.
You can customize the appearance of the map by changing the Map Layer
properties. Go again to the Map Layer property dialog box and check the "Use
Page
48

Rama Rao
bubble size to visualize data" to analyze the data by varying bubble size centered
on areas:

Check the "Use bubble size to visualize data" option


After changing the above property, you will see different bubbles of varying size
representing the analytical data value area wise; a bigger bubble represents a
bigger value and a smaller bubble represents a smaller value as shown below:

Page
49

Rama Rao

World wide sales map report


You can even change the color combination of the area by using the predefined
combination or manually. To use standard color combination, again go to the Map
Layer properties, check "Use polygon colors to visualize data" and then select the
already available color combination from the combo-box as shown below:

Page
50

Rama Rao

Change color theme


This is how it will look like after changing the color combination to "Dark-Light" as
shown below:

Page
51

Rama Rao

World wide sales map report in Dark-Light

Page
52

Rama Rao

Implementing Page Break while exporting bulk data to Excel 2003


1. Create a Tabular report same as below/earlier in this document,

2. In Groups Editor, Click on Row Group Arrow mark, Add Group Parent
Group,

3. In Tablix group editor, Click fx for expressions and following expression to


limit the number rows to be displayed per page in any rendering/export
formats, (we have to put Group by expression for the new group,
Provide the expression to makes group of each 65000 record sets,
Expression: =CInt(Ceiling(RowNumber(Nothing)/65000))
Click OK

Page
53

Rama Rao

4. Row Group (Group1) has been create as show in the below screen shot,

5. In the Report Layout, Group1 has been created. Right Click on Group1
column Delete Column,

6. In Delete Column window, Select Delete Column only radio button and
click Ok. Now you can see the Group1 column is deleted but Group1 is still
available in the report that groups every 60,000 records,

7. In Row Groups section, Click

Properties,

Page
54

on Group1 Select Group

Rama Rao

8. In Group Properties Editor, Select Page Break page, check the

following page break options,


Check Between each instance of a group
Check, Also at the end of a group and click ok.

and also

9. Right click on the Tablix go to Tablix property. Tablix property

windows opens: Check Add Page break after and in column


header, check Repeat header columns on each page.

Page
55

Rama Rao

Steps to Create Document Map:


A document map in an SSRS report, provides pointers/links to certain report items
in your report.
If you have a document map in your report, it will appear in the left most pane.
Clicking on any of the links, in the document pane, jumps the users directly to the
report item. It is similar to the table of contents. Please note that clicking on the
document map links, refreshes the report.
Lets look at an example for a document map.
Step 1: Create a blank report by connecting to Adventure works database or use
any of the existing report,

1) Design a report.
2) Add a Group to the column for which you want to configure document map and in this case I
created group for Categories Field as shown below.
3) Right click on group and select group properties as shown below.

Page
56

Rama Rao

4) Select Advanced Tab in properties pane.


5) Select the Field from the drop down list and click on OK and in this case it is
EnglishProductCategoryName as shown in the below image.

Then go to Preview report and you can find the Bookmarks on the left hand side and if you select any
bookmark item then it will take you to the particular item in report. PFB the screenshot showing the
bookmark for the report created.

Page
57

Rama Rao

Page
58

You might also like