Creating multiple data regions and charts in reports
This recipe will show how data regions can be used to render data. A data region in simple definition is a subreport report that shares the parameters and datasets, and is present inside the report design itself. This and the following recipe will help you understand how multiple data regions can be created in SSRS. The first of the two data regions will display the detailed customer transactions, while the second data region will show a pie chart that shows the total value of the transactions against each customer group.
Getting ready
This and the other recipes in the chapter will be extending the report built in this section. Working through Chapter 1, Understanding and Creating Simple SSRS Reports, should make it easier to create SSRS reports. So following the guidelines learned from the previous chapter, create a simple SSRS report using the following steps:
- Create a
PktCustTransList
query, which includes theCustTable
andCustTrans
tables. Remove the unwanted fields and retain only the fields that are shown in the following screenshot: - Open Visual Studio and create a new Report Model Project named
PktCustTransReport
and create a dataset that refers to thePktCustTransList
query. - When selecting the fields in the query window, select all the fields and the
name
data method fromCustTable
.
How to do it…
Multiple data regions can be created as follows:
- Drag the CustTrans dataset to the auto design node. This will create a
Table
design layout. - The grouping ability of the data regions helps in presenting the data effectively, by ordering and organizing them.
- Drag the CustGroup field to the Group on node and then drag the AccountNum field to the Group on node from the dataset.
- Expand the Group on node and navigate to the Row property and drag the field's Currency, Party_Name to the AccountNum group node.
- Grouping helps in rendering the data in a summarized view. The order of the grouping property determines the order in which they are summarized. In this case, the grouping is done by the customer group followed by the customer:
- Preview the report and see how multiple groupings look in action:
How it works…
If you have been working with the legacy reporting system, your mind might tune in to find two records, one for the customer table and the other for the customer transactions. It works differently with SSRS, where the data is completely flattened. This means if the customer table has records c1
, c2
and the transactions table has t11
, t12
, t21
, t22
records, then the flattened dataset of an SSRS will have four records, where each line will hold c1 t11
, c1 t12
, c2 t21
and c2 t22
.
Grouping helps recreate relational data on a flattened dataset. For example, Customer – Customer Transaction. So here the grouping helps classify the transactions by customer and in turn acts as the header record.