Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Jan 16, 2006

Mastering OLAP Reporting: Display a Dataset Field in a Report Page Header - Page 6

By William Pearson

Procedure: Display a Dataset Field within the Report Page Header

All that remains in completing the modifications to the report is to add a Page Header, from which we will display the page information, coupled with the respective Sales Reason Type that is presented on the report.

1.  From the main menu, select Report --> Page Header, as shown in Illustration 38.


Illustration 38: Adding a Header to the Report ...

The Page Header area appears in the Layout view.

2.  Drag the Body bar (separating the Page Header from the Report Body) down to the fourth or fifth "tick" on the meter appearing on the left side of the canvas, as depicted in Illustration 39.


Illustration 39: Increasing Height of the Page Header ...

3.  Drag a textbox from the Toolbox to the right side of the report Page Header, as shown in Illustration 40.

Click for larger image

Illustration 40: Adding a Textbox to the Right Side of the Page Header ...

Before we can reference the Sales Reason Type Dataset field, as stipulated in the business requirements, within the Page Header of the report, we need to ascertain the name of the "container" of the Dataset field within the report body.

4.  Right-click the new textbox, leftmost within the Body of the report, which contains the Sales Reason Type value.

5.  Select Properties from the context menu that appears, as depicted in Illustration 41.


Illustration 41: Adding an Expression to the Textbox ...

The Textbox Properties dialog opens, defaulted to the General tab, as shown in Illustration 42.


Illustration 42: Determining the Reference for the Sales Reason Type Report Item ...

We can see that the textbox is named, simply, textbox5 (or similar default Name assigned by the design environment), as seen in Illustration 42 above. I won't go into the value of following a logical object naming convention in this article – although I typically establish such a convention in most engagements – the point here is that, whatever the reference Name, we must know it to use it in the steps that follow.

6.  Click OK to close the Textbox Properties dialog.

Keeping the textbox Name in mind, we will continue with our new textbox in the report Page Header, taking the following steps:

7.  Right-click the textbox we added on the right side of the report Page Header earlier in this section.

8.  Select Expression ... from the context menu that appears, as depicted in Illustration 43.


Illustration 43: Adding an Expression to the Textbox ...

The Expression Editor opens.

9.  Type (or cut and paste) the following expression into the upper pane of the Edit Expression dialog:


= "Page: " & Globals!PageNumber & " of " & Globals!TotalPages & vbcrlf & 
 "Sales Reason Type: " & ReportItems!textbox5.Value

The expression above concatenates the text "Page: " with PageNumber, a member of the Globals collection within Reporting Services. It then concatenates the combination of text " of ," and another Globals member, TotalPages. Next, we insert vbcrlf to tell Reporting Services to begin a new line. We then add the text "Sales Reason Type: " before finally adding a reference to the value of textbox5, a member of the ReportItems collection.

In the above example, we expose an approach to overcoming the obstacle presented by the inability to display a Dataset field directly within the report Page Header. We have drawn the desired Dataset field into the body of the report. Once we have done this, we can use that field, now a member of the ReportItems collection, within the Page Header. Although the header does not allow Dataset fields, it does allow ReportItems members; herein lies our opportunity to achieve our ends – and to meet the business requirements of our hypothetical client.

The Expression Editor appears, with our input, as shown in Illustration 44.


Illustration 44: The Expression Editor with Our Input

10.  Click OK to accept our input to the Expression Editor.

11.  Click the textbox, once more, if necessary to select it.

12.  Adjust the Font size to 8 point, in the toolbar above the Layout tab, as shown in Illustration 45 (or within the Properties pane for the textbox, if desired).


Illustration 45: Adjusting the Font Size ...

13.  Resize the textbox to a width and height that makes sense for the display of its contents, experimenting as desired.

The Page Header of our report appears within the Layout tab, similar to that depicted in Illustration 46.


Illustration 46: The Textbox within the Report Page Header

We have inserted a Dataset field into the Page Header via the knowledgeable use of the ReportItems collection. We will ascertain the effectiveness of our work in the section that follows.

Verification: Preview the Report and Inspect the Successful Display of a Dataset Field within the Report Page Header

Let's preview the report to inspect the results of our handiwork.

1.  Click the Preview tab.

RS025_Dataset Field in Header executes, and returns the data for the default parameter setting, All Products, as shown in Illustration 47.


Illustration 47: The Report Appears – with Dataset Field in the Page Header ...

Advancing pages further confirms the effectiveness of our solution: basing page breaks upon the field, through the mechanism of the Sales Reason Type Group properties settings, ensures that the Dataset field changes appropriately. I hope that this straightforward use of the ReportItems collection lends itself to extrapolation into uses that truly leverage its latent power. This is only one avenue to meeting the immediate requirement; more importantly, it is the tip of the iceberg in possible creative uses for the ReportItems collection.

2.  Select Save --> Save All to save all work to this point.

3.  Select File --> Exit to leave Reporting Services, when ready.

Conclusion ...

In this article, we examined a means of surmounting an apparent shortcoming of Reporting Services, our inability to directly present Dataset fields in the Page Header or footer of a report. As we noted in the introduction to the session, there are different ways to overcome this inconvenience (and that of most perceived deficiencies) in a business intelligence application as flexible as Reporting Services. We explored one of these approaches, the use of an "alias," supported by the ReportItems collection exposed within the Reporting Services development environment.

As a part of preparing the backdrop for a practice exercise surrounding the setup of support for the display of a Dataset field within a report Page Header, we created a copy of an existing OLAP sample report to leave the original intact for other uses. We made structural changes to the clone report, based upon a sample SQL Server Analysis Services cube, to meet the business requirements of a hypothetical group of information consumers, including the need to display a Dataset field in a report Page Header. Finally, we previewed the report to ascertain the effectiveness of our solution. Throughout our practice session, we discussed the results obtained within the development techniques that we exploited.

» See All Articles by Columnist William E. Pearson, III

Discuss this article in the MSSQL Server 2000 Reporting Services Forum.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM