SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
SQL Azure
Developer
General DBA
ASP.NET / ADO.NET
SQL Azure

USEFUL SITES :

ASP.NET Tutorials
Windows and SQL Azure Tutorials
Cloud Hosting Magazine
SharePoint Tutorials
Windows Server Help

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server

More     
 
Latest FAQ's

Add Node to A SQL Server failover Cluster failed with invalid ...
SQL Server Destination remote server error
Setting Up Data And Log Files For SQL Server
Will Check Constraints Improve Database Performance?

More     
   
Latest Software Reviews

dbForge Review
Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008

More     

articles >> business intelligence >> Same Report but Different Methods in SQL ...

Same Report but Different Methods in SQL Server Reporting Services

By : Dinesh Asanka
Mar 12, 2008

Page 2 / 3


Method 1 : SubReports
A SubReport will be the easiest way of doing it. In this case we need to create one main report (MainReport.rdl) where the user select the report type they want and three sub reports for colour (colorreport.rdl), class (classreport.rdl) and subcategory (SubCategoryReport.rdl).

First we create the SubReport. Let us start with the colour SubReport.

After creating the colour report, we need to add a data set for the report and for that we will use the following query:


SELECT YEAR(SOH.OrderDate) Year 
    ,Color
    ,SOD.LineTotal
FROM   Sales.SalesOrderDetail SOD
INNER JOIN   production.product PROD 
  ON   SOD.Productid = PROD.ProductID
INNER JOIN   Sales.SalesOrderHeader SOH
  ON   SOH.SalesOrderID = SOD.SalesOrderID


From the report format, we can imagine that this report needs a matrix rather than table, as the report has data dependent columns and rows. You can see that Year is also a variable as well as the color.

After dragging a matrix control to the report body, drag the Year column to Columns and Colour to Rows. Using the matrix it is very easy to provide a total column. Simply right click the Year column and select subtotal which will provide the sub total of the column, nwo do the the same to the Color column.

Next we will add a graph. Drag the graph control from the tool box and then drag year to the series field, color to category field and Line total to the data field. After doing this you should have a report layout as following:



To create the other sub reports for subcategory and class it is almost the same process as the color report. Here is the T-SQL queries for the datasets of class and subcategory respectively.

--Query for Product Class
SELECT YEAR(SOH.OrderDate) Year
    ,CASE
          WHEN Class IS NULL THEN 'N'
          ELSE Class
     END class
    ,SOD.LineTotal
FROM   Sales.SalesOrderDetail SOD
INNER JOIN   production.product PROD
  ON   SOD.Productid = PROD.ProductID
INNER JOIN   Sales.SalesOrderHeader SOH
  ON   SOH.SalesOrderID = SOD.SalesOrderID

--Query for Product Subcategory
SELECT YEAR(SOH.OrderDate) Year
    ,PSC.Name
    ,SOD.LineTotal
FROM   Sales.SalesOrderDetail SOD
INNER JOIN   production.product PROD
  ON   SOD.Productid = PROD.ProductID 
INNER JOIN   Sales.SalesOrderHeader SOH 
  ON   SOH.SalesOrderID = SOD.SalesOrderID
INNER JOIN   production.productsubcategory PSC
  ON   PSC.ProductSubCategoryID = PROD.ProductSubCategoryID
--Where Month(SOH.OrderDate) = 1

So now we have three sub reports ready. Now we have to create the main report to link to these subreports.

Let us see how to create the main report.

The main report will have report parameter so that a user can choose the report type they want.

For the sake of simplicity I have assigned the same values for both the label and value of the Type report parameter. After that drag and drop a sub-report component to the report body from the toolbox and select colorreport from the sub-report list in the General tab of the sub-report component as illustrated below:

 

Similarly, add another two sub-reports components to the reports and assign ClassReport and SubcategoryReport respectively. Now we need to display the sub-report one at a time. That will depends on the users selection. For this we need to add an expression to the Initially Visibility option at the Visibility tab of the sub-report component. It is a very simple expression which is =IIF(Parameters!Type.Value="Color",False,True). This means that the colour report will be visible only when the user has selected the Colour option. For Product class and subcategory sub-report add the =IIF(Parameters!Type.Value="Class",False,True) and =IIF(Parameters!Type.Value="SubCategory",False,True) expression respectively. You can extend the visibility option to the other two sub-reports as well.

Now if you run the Main Report, select the colour option from the type list and click the View Report button you will be able to see following report.

You can see that you can only view the data for colour and similarly you can verify the data for the other two parameters. The issue with this method is you have to have  four reports.  The more reports the more maintenance that is required.


<< Prev Page     Next Page>>    








C# Help and Tutorials | PHP MySQL Tutorial | Sharepoint Tutorial | Azure Tutorial | Cloud Hosting Magazine | ASP.NET Tutorials | Windows Server Help | Windows Phone Pro | Silverlight Ace | Visual Studio Tutorials | Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 2010 Jude O'Kelly. All rights reserved