SSRS Exercise 1 - Creating a Basic Report

Create a report server project

1) In Visual Studio, open the File menu, select New > Project.



2) In the left-most column under Installed, select Reporting Services. In some cases, it may be under the group Business Intelligence.




3) Select the Report Server Project icon   ssrs_ssdt_report_server_project   in the center column of the New Project dialog box.
    4) Change the project name to Analysis Services Exercise, which also changes the solution name, and
    then click OK
      5) The Analysis Services Exercise project is displayed in the Solution Explorer pane on the right.


      Create a new report definition file

      1. In Solution Explorer, right-click Reports, point to Add, and click New Item. (If the Solution Explorer window is not visible, from the View menu, click Solution Explorer).

      2. In the Add New Item dialog box, under Templates, click Report.



      3. In Name, type Sales Orders.rdl and then click Add. Report Designer opens and displays the new .rdl file in Design view.



      NOTE: Report Designer is a Reporting Services component that runs in Business Intelligence Development Studio. It has two views: Design and Preview. Click each tab to change views.

      Set up a connection

      1. In the Report Data pane, click New and then click Data Source. If the Report Data pane is not visible,from the View menu, click Report Data.

      2. In Name, type AdventureWorks.

      3. Make sure Embedded connection is selected.

      4. In Type, select Microsoft SQL Server.

      5. In Connection string, type the following:

      Data source=localhost; initial catalog=AdventureWorks

      6. Click OK. A data source called AdventureWorks is added to the Report Data pane.

      Define a Transact-SQL query for report data

      1. In the Report Data pane, click New, and then click Dataset. The Dataset Properties dialog box opens.

      2. In the Name box, type AdventureWorksDataset.

      3. Click the Use a dataset embedded in my report radio button. Make sure the name of your data source, AdventureWorks, is in the Data source text box, and that the Query type is Text.

      4. Type, or copy and paste, the following Transact-SQL query into the Query box.


      SELECT

       soh.OrderDate AS [Date],

       soh.SalesOrderNumber AS [Order],

       pps.Name AS Subcat, pp.Name as Product,

       SUM(sd.OrderQty) AS Qty,

       SUM(sd.LineTotal) AS LineTotal

      FROM Sales.SalesPerson sp

       INNER JOIN Sales.SalesOrderHeader AS soh

       ON sp.SalesPersonID = soh.SalesPersonID

       INNER JOIN Sales.SalesOrderDetail AS sd

       ON sd.SalesOrderID = soh.SalesOrderID

       INNER JOIN Production.Product AS pp

       ON sd.ProductID = pp.ProductID

       INNER JOIN Production.ProductSubcategory AS pps

       ON pp.ProductSubcategoryID = pps.ProductSubcategoryID

       INNER JOIN Production.ProductCategory AS ppc

       ON ppc.ProductCategoryID = pps.ProductCategoryID

      GROUP BY ppc.Name, soh.OrderDate, soh.SalesOrderNumber, pps.Name, pp.Name,

       soh.SalesPersonID

      HAVING ppc.Name = 'Clothing' 

      5. Click the Query Designer button. The query is displayed in the text-based query designer. You can toggle to the graphical query designer by clicking Edit As Text. View the results of the query by clicking the Run (!) button on the query designer toolbar.You see the data from six fields from four different tables in the AdventureWorks database.

      6. Click OK to exit the query designer. Click OK to exit the Dataset Properties dialog box. Your AdventureWorksDataset dataset fields appear in the Report Data pane.

      Add a Table data region and fields to a report layout

      1. In the Toolbox, click Table, and then click on the design surface. Report Designer draws a table data region with three columns in the center of the design surface. The Toolbox may appear as a tab on the left side of the Report Data pane. To open the Toolbox, move the pointer over the Toolbox tab. If the Toolbox is not visible, from the View menu, click Toolbox.

      2. In the Report Data pane, expand the AdventureWorksDataset dataset to display the fields.

      3. Drag the Date field from the Report Data pane to the first column in the table.

      When you drop the field into the first column, two things happen. First, the data cell will display the field name, known as the field expression, in brackets: [Date]. Second, a column header value is automatically added to Header row, just above the field expression. By default, the column is the name of the field. You can select the Header row text and type a new name.

      Alternately click move your mouse cursor to the first cell on table, a small symbol for field list appears click on it and select the desired field.

      4. Drag the Order field from the Report Data pane to the second column in the table.

      5. Drag the Product field from the Report Data pane to the third column in the table.

      NOTE: To add a new column in table right click the last column and select insert column -> right

      6. Drag the Qty field to the right edge of the third column until you get a vertical cursor and the mouse pointer includes a plus sign [+]. When you release the mouse button, a fourth column is created for [Qty].

      7. Add the LineTotal field in the same way, creating a fifth column.

      8. The following diagram shows a table data region that has been populated with these fields: Date,

      Order, Product, Qty, and Line Total.


      Preview & Save the report

      1. Click the Preview tab. Report Designer runs the report and displays it in Preview view.


      2. Save the report project. On the File menu, click Save All.

      Format a date field

      1. Click the Design tab.
      2. Right-click the cell with the [Date] field expression and then click Text Box Properties.
      3. Click Number, and then in the Category field, select Date.
      4. In the Type box, select January 31, 2000.
      5. Click OK.

      Format a currency field

      1. Right-click the cell with the [LineTotal] field expression and then click Text Box Properties.
      2. Click Number, and in the Category field, select Currency.
      3. If your regional setting is English (United States), the defaults should be:
       Decimal places: 2
       Negative numbers: ($12345.00)
       Symbol: $ English (United States)
      4. Select Use 1000 separator (,). If the sample text is: $12,345.00, then your setting is correct.
      5. Click OK.


      Format header rows and table columns

      1. Click the table so that column and row handles appear above and next to the table.


      2. The gray bars along the top and side of the table are the column and row handles.
      3. Point to the line between column handles so that the cursor changes into a double-headed arrow. Drag the columns to the size you want.
      4. Select the row containing column header labels and from the Format menu, point to Font and then click Bold.
      5. To preview your report, click the Preview tab. It should look something like this: 












      Post a Comment

      Previous Post Next Post

      Contact Form