Welcome!

Linux Authors: Dana Gardner, Liz McMillan, Gary Kaiser, Lori MacVittie, Pieter Van Heck

Related Topics: .NET, Linux

.NET: Book Excerpt

Learn SQL Server 2008 Reporting Services

Chapter 6: Working with Report Builder 2.0

Report Builder 2.0 user interface description

Read Part 2 of this article here: http://jayaramkrishnaswamy.sys-con.com/node/1227111

Report Builder is a report authoring tool and the basic procedure for authoring a report consists of the following steps:

    http://images.packtpub.com/images/bullet.gif);">
  • Report planning
  • Connecting to a source of data
  • Extracting a dataset from source
  • Designing the report and data binding
  • Previewing the report

Book JacketAlthough deploying the report is not included in the above, Report Builder can deploy the report as well. It is not always necessary to deploy a completed report, as any part of a report definition file can be deployed. This makes modifying a report on the server very flexible.

 

In the following sections, the various parts of the Report Builder interface will be described starting at the very top and going to the bottom of the interface

The menu for file operations

Report Builder 2.0 can be accessed from Start | All Programs | Microsoft SQL Server 2008 Report Builder | Report Builder 2.0.

This brings up the Report Builder Interface 2.0 as shown with the design area containing two icons:Table or Matrix and Chart. Each of these will launch a  related wizard which will step you through the various tasks. The Report Builder 2.0 interface is very similar to Office 2007. More than one instance of Report Builder can be launched.

Report Builder 2.0 User Interface

At the very top of the following screen shown you have the undo and redo controls as well as a saveicon.

Undo / Redo controls

When you click on the save icon the Save as Report window gets displayed as shown. Here you provide a name for the report. The default save extension is  *.rdl and it will be saved to the report server. It may also be persisted to a folder on your machine.

Folders on the Report Server

Clicking on the Office Button (top left) opens a drop-down window shown in the following screenshot:

Opening File menu using the 'Office Button'

In this window, you can carry out a number of tasks such as creating a new report, opening an existing report, saving a report, and saving a report with a different name.

The Save button saves it to the default location seen earlier and Save as invokes the same window to save the report with a different name as seen earlier displying the report server instance as the Save tolocation.

The Recent Documents pane shows the more recent reports created with this tool. New allows you to create a new report. When you click on Open, the following Open Report window gets displayed with the default location http://Hodentek2:8080/ReportServer_SANGAM/My Reports. You will also notice the message: This folder is not available because the My Reports feature is not enabled on the computer. Also the Open Reports window allows you look for reports with the extension .rdl.

Therefore, unless the My Reports feature is enabled, this window is unusable. This is supposed to be possible from Report Manager but there are no controls in Report Manager that would do this. An alternative was suggested by one of the MSDN forum moderators (seehttp://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/6c695160-29e8-4185-be6d-5fe027a6975c/). Hands-on exercise (Part 2) will describe how you may enable My Reports. The idea of My Reports is similar to My Documents where each user can keep his reports.

When the Options button (in the previous screenshot) is clicked it opens the window Report Builder Options window with two tabbed pages Settings and Resource shown as follows:

 

 


Report Builder Settings

Here you can view, as well as modify, Report Builder settings. The defaults are more than adequate to work with the examples in this book.

Clicking on the Resources button brings up this interesting window which enables you to interact with Microsoft regarding SSRS activities, concerns, community, and so on. If you are serious about Reporting Services, these are very valuable links. The About button when clicked can provide you with Report Builder version information.

 

 

Accessible Resources

The ribbon

The main menu consists of Home, Insert, and View menu items which are part of the "ribbon". The ribbon introduced by Microsoft in Office 2007 is actually a container for other toolbar items. The ribbon is the replacement for the classic menus, toolbars, and is supposed to be more efficient and discoverable by the user. In fact you see a lot more on the "ribbon" than in the classic menu.

Home

The next figure shows the Home menu with its toolbar arranged from left to right and divided into sections. The Run toolbar item with the title Views when clicked would run the report open in the design view (in fact, even without a report open in the design view, the report can be run. The result would be the current date and time getting displayed in the center of the screen of an untitled report which has just ExecutionTime as the only item in the report).

The Ribbon

The Font, Paragraph, Border, and Number toolbar sections become enabled if parts of a report need editing. The formatting of textboxes in the report, the formatting of numbers in the report, and the alignment of components in the layout can all be independently managed using these toolbar items.

Insert

When you click on the Insert menu item on the "ribbon", the tabbed page for this item is displayed as shown in the following screenshot:

Ribbon menu

It has four sections: Data Regions, Report Items, Subreports, and Header & Footer. These are all the normal items that are used either individually or together to make up a report. There can be more than one data region in a report.

Data Regions

In the Data Regions section you have both the Tablix (Table, Matrix, and List) and the graphic controls that can be bound to data—the Chart and the Gauge. Gauge is new in SQL Server Reporting Services 2008. Chart and gauge implementations are the off shoot of collaboration with Dundas (http://www.dundas.com/). Report Builder is built in such a way that the dataset must be defined before any of the data regions are added to the report body. For the purpose of describing the various data regions in this section, it is assumed (in order to get the screen shots shown here) that a dataset has been defined and the default wizards on the design surface have been removed.

Table

The Table is meant for displaying data retrieved from a database either all data detailed in groups or a combination (some grouped and some detailed) of both. It has a fixed number of columns which can be adjusted at design time. The table length expands to accommodate the rows.

Data can be grouped by a single field or by multiple fields. Expression designer can be used in grouping as well. The grouping is carried out by creating row groups. Static rows can be added for row headings (labels) and totals. Aggregates for groups can be added. Both detailed data as well as grouped data can be hidden initially and the user can interactively reveal the data needed by drill downs.

When you click on Insert | Table | Insert Table and then click on the design surface you can add a table to the design area. The table appears as shown with handles to adjust its dimensions. The table can be dragged to any other location on the design surface (the body of the report) as well.

Designing a layout

 

 

After placing the table, which by default has three columns and two rows, when you click on any other part of the design area you will see the table as shown. When you hover over the cell marked Data on the table you will see a little icon. This icon is a minimized version of the dataset fields. The grayed out feature that surrounds the table indicate the position of the rows and columns of the table. It also shows such other features as whether it is a detail, or whether it is a group. In the case of group, within a group the feature would indicate the nesting schematically as well. When you want to increase the size of a column or a row you can drag the double headed arrow that gets displayed when your cursor is placed between two columns or between two cells as shown.

 

Adding a column

When you click on the dataset icon in the cell Data you get a drop-down list containing the fields in the dataset as shown. You can choose any of the fields to occupy the cell you clicked and the corresponding header will be added to the table. In this particular dataset there are nine fields and you can choose any of them to occupy the cell.

 

Getting a column listing

 

When you right-click on a cell, a drop-down menu will be available. It can be used for the following:

    http://images.packtpub.com/images/bullet.gif);">
  • Work with the highlighted textbox (each cell of the table is a textbox) including to copy, cut, delete, and paste contents.
  • Work with the properties of the Textbox.
  • Populate the textbox with an expression using the expression builder. The expression builder gets displayed when fx Expression is clicked.
  • Use Select to select the body or the Tablix.
  • Insert a new column or a new row. Columns can be added to the right or the left of the clicked cell and rows can be added above or below the clicked cell.
  • Delete columns and rows.
  • Add a group. Both row and column groups can be added.
Extending the report horizontally

 

When you click on the properties of the textbox, the Text Box Properties window is displayed. The textbox has several properties which are arranged on the left as a list with each item having its own page as shown. The Help button on any of the pages will take you directly to the definition of the properties and is extremely useful.

Options in configuring a textbox

In the General page, you can make changes to the elements in the Name, Value, and Sizing optionspage as shown. The Value is one which you choose among the column values (from the drop-down) from the dataset. You may also add a text for the ToolTip, which will display this text when the report is generated and this cell is accessed by hovering over it in the report. Alternatively you can set the Valueand Tooltip using fx—the button that brings up the Expression window.

In the Number page you can set the number and date data type formatting options for the cell that contains a number or a date. This is what you normally would find in most Microsoft products such as Excel and Access.

In the Alignment page you can choose the vertical and horizontal alignments as well as the padding of the textbox content from the edges of the cell.

Similarly the Font and Border properties are the same ones you find in most Microsoft products.

The Fill property lets you add or change background color to the report as well as add a graphic element. The graphic element can be embedded, external, or originate from a database (being one of the fields accessed). Expressions can be developed to set a desired color for the Fill.

The Visibility of the textbox can be any of Show, Hide, Show or Hide based on an expression. In each of these cases the visibility can be toggled when another table cell is clicked (which can be chosen). This page also gives access to the Expression window which is similar to the MS Access expression builder.

The Interactive Sorting page allows you to define interactive sorting options on  the textbox.

Matrix

Matrix provides a similar functionality (roughly speaking rows against columns) to cross-tab reports in MS Access (http://aspalliance.com/1041_Creating_a_Crosstab_Report_in_Visual_Studio_2005_Using_Crystal_Reports.all) and Pivot Table dynamic views (http://www.aspfree.com/c/a/MS-SQL-Server/On-Accessing-Data-From-An-OLAP-Server-Using-MS-Excel/3/). The matrix should have at least one row group and one column group. The matrix can expand both ways to accommodate the data, horizontally for column groups and vertically for row groups. The matrix cells (intersection of rows and columns) display summary information (aggregates).

When you click on Insert Matrix in the Insert menu and drop it on the design area of Report Builder 2.0, it gets displayed as shown in the following figure:

Barebones 'Matrix' report

Now if you click inside the boundary of the (2x2) empty matrix you will see more features of the matrix as shown in the following screenshot. The basic elements are the ColumnGroup (Column Groups), theRowGroup (Row Groups), and the Data. The group information is also displayed as shown by overlaid lines pointing to them. There needs to be a minimum of one group and one column for the matrix and there could be a hierarchy of column and row groups.

Rich support for enhanced Matrix

 

he row and column group cells have their own properties which can be displayed when you right-click on them as shown in the next screenshot for the row group. When you right-click on the cell markedRows, the following drop-down menu  pops up.

 

Options & Choices

In addition to the properties that you can set for the textbox in that cell, you have additional submenu items that work with the grouping and totaling. These are part of representing data in a matrix.

Each of the Tablix for the Rows and Columns has the additional submenu items which are shown here for the Rows. Similar ones apply for the Columns as well. These are useful when you want to create nested groups. With the Matrix design interface in SQL Server 2005 this would not have been possible.

Add Group

    http://images.packtpub.com/images/bullet.gif);">
  • Row Group
      http://images.packtpub.com/images/bullet.gif);">
    • Parent Group...
    • Child Group...
    • --------------------
    • Adjacent Above
    • Adjacent Below

Row Group

    http://images.packtpub.com/images/bullet.gif);">
  • Delete Group
  • Group Properties

Add Total

    http://images.packtpub.com/images/bullet.gif);">
  • Before
  • After

In addition to the above, each of the items Rows and Columns cells has the following items as well. These specify how new columns and rows are inserted with reference to the current cell as shown. The differences are due to the geometrical positions that are allowed for the new columns or rows as shown.

For the "Columns" cell:

Insert Column

    http://images.packtpub.com/images/bullet.gif);">
  • Inside Group-Left
  • Inside Group-Right
  • ------------------
  • Outside Group-Left
  • Outside Group-Right

Insert Row

    http://images.packtpub.com/images/bullet.gif);">
  • Inside Group-Above
  • Inside Group-Below
  • ------------------
  • Outside Group_Above

For the "Rows" cell:

Insert Column

    http://images.packtpub.com/images/bullet.gif);">
  • Inside Group-Left
  • Inside Group-Right
  • ------------------
  • Outside Group-Left

Insert Row

    http://images.packtpub.com/images/bullet.gif);">
  • Inside Group-Above
  • Inside Group-Below
  • ------------------
  • Outside Group_Above
  • Outside Group_Below

Besides using a cell as a starting point, one could also use the rows as a whole or column as a whole to add further structure as shown in the next figure. Of course you need to use the proper submenu option to arrive at a particular matrix structure. Clicking at the indicated points would let you choose the structure you want for your matrix. If you click at the location shown for the Tablix you could choose to the delete the whole matrix. The Tablix graphical arrangement gives you the maximum flexibility in extending the matrix in 2-dimensions.

Configuring a Tablix region - Options

 

List

The list data region repeats for each row of data. List element provides a single container for the data which can be used to generate what are called Free Form Reports. In this kind of report there is no rigid structure such as a table for the data. You can also place a list inside another list or even a chart inside a list. You can drag a column from a dataset and drop it into the list. You can work with the list using the properties of the Rectangle it contains as well as its Tablix properties.

As described earlier, the design interface is very flexible and you can leverage all features provided by the Tablix structure like displaying details and adding groups either independent, or nested. The properties pages described earlier allow you to sort and filter grouped data.

When you drop a List on the design surface you will see just a single cell as shown. You can change its dimensions to suit your needs.

 

List Control


When you click on the List you can access its handles as shown:

 

Configuring a report

When you add a List, there is one column and one row (just one cell). This can be extended in both directions by choosing the appropriate submenu items. These can be displayed by right-clicking on the handles as shown:

Inserting elements into a List

 

Chart

A picture tells lot more than a bunch of numbers, and charts (graphs) aggregate the whole range of data that is highly informative and aesthetically pleasing. Charts have a myriad of properties, both with regard to how they are linked to data as well as their visual properties that it is hard to justify describing them in an abbreviated fashion.

Charts are basically used while creating a graph from the data to summarize important and relevant information. There are two ways you can work with chart in Report Builder 2.0. The easiest is to use theChart Wizard. The other way is to start with a chart template and then associate it with a dataset.

There are many chart types such as bar charts, column charts, line charts, pie charts, area charts, polar charts, range charts, scatter charts and so on. The following screenshot schematically shows the various supported chart types. The chart type would depend on the data that it represents. Generally a chart should help visualize the data. A chart has its data region as well, its Tablix properties.

You can insert a chart on the report body by clicking Insert | Chart |Insert Chart and clicking again on the body of the report. This brings up the Select Chart Type window as shown:

Chart and Chart Options

 

Here you have number of options as shown. For each of these choices you have a number of other options as shown on the right-hand side when you choose the Column type.

Assuming you choose the default (the one highlighted in the above figure) and click on the OK button, the type of chart you chose gets added to the design area of the report as shown. You can increase the size of the chart both ways by dragging the handles.

Interface for designing a chart

 

 

 

When you double-click inside the chart, you see the drop-zones on its three sides as shown. These are the areas into which you can drag-and-drop columns from the Dataset or use the minimized dataset icon that gets displayed when you hover over this area.

 

Bringing data to chart

When you right-click on any of these areas, you can access the various ways you can work with the charts as shown:

 

Configuring a chart

The important chart related items are category fields, series fields, and data fields. You can work with all properties of the chart from this drop-down menu and even change the type of chart you want to develop.

Gauge

This is new in Reporting Services 2008. Like chart, gauge is also a data region. Gauge has only a single data region unlike a chart. It has the look of any industrial meters (measuring instrument) with a range of values and the indicator showing the present value or some configurable value. They can be used together with both table and matrix elements.

When you add a gauge to a report, it comes up positioned within a gauge panel. The properties of this can be accessed when you click outside the boundary of the gauge. When you want the gauge to display data, you should associate its data property with the dataset. Gauge, like chart also has a myriad of properties which can be accessed from its Properties window.

In Hands-on exercise, (Part 2) you will be adding a radial gauge to display the data and a linear gauge to display an average.

Report Items

Textbox, image, line, and rectangle are the items you find in the Report Items section of Insert. You will be using textbox and image both of which may be bound to related as well as unrelated database variables. In the case of textbox, you have an option to use a static text, a field from the built-in fields, or connected to one of the fields from the dataset. A table added to a report has textboxes in its cells, but you can add a textbox outside the table and bind it to an aggregate value related to  the dataset.

Similar to the textbox, an image added to the report can be embedded, originate from an external source; or being one of the dataset fields. An image can be added to the current report by right-clicking the Images folder in Report Builder and picking an image from your hard drive which can then be simply embedded in the report using the Image report item. This way you can add a logo to your report.

A line cannot be bound to the dataset. Its purpose is purely to provide support as a graphic separator element. The rectangle is also used to improve the visible appeal. However, it can contain other items, even data regions. You can control the rendering behaviour of items placed inside a rectangle (parent control) for the controls placed inside the rectangle. The rectangle will be an anchor for the items placed within it and move when the rectangle is moved in the report design.

When the line or the rectangle is used inside data regions you may use their RepeatWith property to allow them to be rendered when the report gets displayed.

Subreports

A subreport is a child of a main report. The main report is a container for the subreport(s). TheSubreport section in the Insert menu item of the "ribbon" allows you to add a subreport. The parent report and the subreport are stored usually in the same folder on the report server. The main report can be designed to pass parameters to the subreport. The parameter then filters the subreport for it to be displayed in a data region of the main report.

Subreports can be separated from main data region of the main report or they can be placed within the data region of the main report. A report can contain more than one subreport.

As described above, the subreport may be placed inside the main report several ways as shown in the following screenshot:

Diffrent ways of nesting a subreport

Header and footer

A report page can contain a header and footer. In Report Builder 2.0 there is page footer by default which contains the built-in parameter ExecutionTime.

Some of the common features of page headers and footers are the following:

    http://images.packtpub.com/images/bullet.gif);">
  • Headers go at the top of the page and footers go to the bottom and they repeat on each page of the report.
  • They both can contain static text, images, lines and rectangles, borders, expressions (lookup the properties of these in Report Builder 2.0).The expressions can include field references for reports from the dataset.
  • You can easily add headers and footers from the Insert menu item in the "ribbon". You can just, as easily, remove them by right-clicking the item and choose to remove the item.
  • The most common use of headers and footers is to display page numbers, report titles, and so on. There are number of built-in fields such as Page Number, Execution Time, Report Name, Total Pagesand so on, which can be dragged-and-dropped on to headers and footers.
  • To display variable data from a dataset in headers and footers you place a textbox and set the value for the textbox using an expression. Choose the appropriate field from the dataset. In a similar manner you can display aggregate values from the expression builder. For data from multiple datasets you cannot reference the fields, rather you should reference the objects in the report.
  • You can suppress these on the first and last pages of a report using the PrintOnFirstPage, PrintOnLastPage properties which can be accessed from their properties.
  • Report headers and footer are not the same as the page headers and footers.
  • Reports that you see with a browser are rendered by the HTML renderer, but the report can be delivered in different formats. Each of them has their own renderer and you should optimize the report for the format you want to deliver.

View

The View menu has very few items as shown:

Report Properties/Show_Hide Items

 

Report Data and Grouping are checked by default. If you want to review or make changes to the properties of objects you place on the report, you should frst place a checkmark for the Properties. Otherwise you will see only the Properties pop-up window that comes up when you right-click an object to look at its properties.

Place checkmark for the Rulers if you want to design measured placement of objects on the report. The rulers become visible when you move around or adjust object sizes.

Report Data, the Report Designer, and the properties

These are the items that you will find just below the "ribbon" assuming you have not disabled Report Data and Properties (these are enabled by default) as shown in the following screenshot. The properties will be that of the object highlighted in the report body.

Report Data

 

Report Data

As seen in the previous figure, you can create New report data; Edit an existing report data (the figure above has an existing report data in the C_Main. It also has three main folders. The built-in fields we saw earlier. The parameters will contain parameters associated with the report. The images folder contains images that can be imported into this folder, which you can embed in a report from your hard drive.

The Report Data is an excellent starting point to create a report from scratch without using wizards displayed in default. When you click on the drop-down handle New the following menu will be displayed.

Report authoring starting from data

All you need to do is to go and configure each of the items from top to bottom as follows:

    http://images.packtpub.com/images/bullet.gif);">
  • The Data Source… will bring up a window where you establish the connection to the datasource.
  • After this, you click on Dataset… to create a query to extract a set from the database which you want to display in your report. When you click on Dataset… you will display the properties of Datasetwhich you can use to design a query visually (only for SQL Server databases), an SQL Statement or import a saved SQL query or RDL file.
  • You can then define parameter(s) by clicking on Parameters… to create a parameter from itsProperties window. You add a parameter if you want to filter your query further to produce a smaller and more manageable set of pertinent information.
  • Click on Images… to choose images from your machine if you need to embed them in the report.

On the other hand, if you already have these you can edit them or delete them.

Report Designer pane

The various parts of this pane are shown in the following screenshot. This has been described earlier. The choices you make in the View pane will show or hide the Groupings at the bottom as well as in theRuler. When you want to create a report from scratch and do not want to use the wizards, you can delete everything on the report and start from scratch.

Report Designer

 

 

For displaying groups of data, the underlying data must support this structure and it is necessary that there exists hierarchical relationships within the data. An example is shown in the following screenshot from the TestNorthwind database used in the exercises.

Relaitonal Data

In Report Builder 2.0, groupings show both row groupings as well as column groupings. If you are starting from the wizard, you will be setting up the row groups as well as column groups as seen in the Arrange Fields page of the wizard. The available fields were moved into column groups and row groups. One of the shortcomings of this wizard is that once you move a field from the available to any of the other three, you cannot move it back. However you can only move between the three. If you go back and return, you have the same arrangement. If you Cancel, you need to start the wizard again. Another problem with this wizard step is that you must add a field to the Value field. What if one wants to show only a few columns of data in a table? However, it is well suited for matrix design. The above shortcomings in the earlier SQL Server 2008 RC0 version have been rectified in the latest version of Report Builder 2.0 bundled with the Feature Pack (https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=371356).

Designing Rows and Columns of a report

The above arrangement would lead to a report's grouping as shown here:

Row and column groupings

Each of the groups shown above has its own properties which can be accessed  by right-clicking the group. For example, the row group [ProductName] in the above. You can then review its Group Properties window as shown in the two following screenshots:

Group properties

When you click on the drop-down item, Group Properties…, the Group Properties window shows up.

Configuring group properties

Clicking on the Next button in the New Table or Matrix wizard's Arrange  Fields page takes you to the window where you can arrange to show the group aggregates. You can show them in several ways depending on the choice you make as shown in the following screenshot:

Choosing a layout

Properties

This window appears, by default, at the right of the report designer pane. It shows all configurable properties of the objects on the report body. You only need to click on the object. Most of the properties become effective as soon as you complete the property and leave that property or move to the next property in the Properties window. If you add custom assemblies, these are also shown in this window.

Server status and tools

At the very bottom of the Report Builder you will get an indication as to the Report Server you are connected to (present case there is only one running) and its status as shown in the following screenshot. You can also change from design to run (preview) by clicking on the respective icons in this figure. You can also enlarge or reduce the size of the report both in design and in preview using the zoom slide.

Last item on the bottom on the UI

Read Generating Reports with Report Builder 2.0

Summary

 

In this part of the article, we had a look at the Report Builder overview. We described the Report Builder 2.0 interface along with the new features that are

incorporated into this version.

The following is what you will find in the remaining part of this chapter:

Hands-on Exercise 6.1: Enabling and reviewing My Reports

Hands-on Exercise 6.2: Modifying a basic report

Hands-on Exercise 6.3:Creating reports with charts and gauges

 

 

 

 

 

 

 

 

 

More Stories By Jayaram Krishnaswamy

Jayaram Krishnaswamy is a technical writer, mostly writing articles that are related to the web and databases. He is the author of SQL Server Integration Services published by Packt Publishers in the UK. His book, 'Learn SQL Server Reporting Services 2008' was also published by Packt Publishers Inc, Birmingham. 3. "Microsoft SQL Azure Enterprise Application Development" (Dec 2010) was published by Packt Publishing Inc. 4. "Microsoft Visual Studio LightSwitch Business Application Development [Paperback] "(2011) was published by Packt Publishing Inc. 5. "Learning SQL Server Reporting Services 2012 [Paperback]" (June 2013) was Published by Packt Publishing Inc. Visit his blogs at: http://hodentek.blogspot.com http://hodentekHelp.blogspot.com http://hodnetekMSSS.blogspot.com http://hodnetekMobile.blogspot.com He writes articles on several topics to many sites.