Skip to end of metadata
Go to start of metadata

Background

A PivotTable is an interactive table that summarizes data to present it in a meaningful way. You can rotate a PivotTable's rows and columns to see different summaries of the source data, or drill down to show details. By displaying different views of data, PivotTable reports allow you to easily compare data, see patterns and relationships, and analyze trends.

Without OfficeWriter, SQL Server Reporting Services cannot export a report to Excel format while maintaining a PivotTable. Report users have to to manually set up PivotTables every time they they export a PivotTable report from Reporting Services to Excel.

With OfficeWriter, you design your PivotTable only once at report design-time. Each time you run the report, OfficeWriter will export the report to Excel and plug the data into the PivotTable. In this section we will explore using PivotTables in a report created with OfficeWriter Designer.

Setup

Icon

The following example uses the AdventureWorks sample database that ships with SQL Server Reporting Services 2005. It is assumed that you already know how to set up a report in Excel using OfficeWriter Designer. If you do not know how to do this, see Quick Start.

This query returns company purchase data from the AdventureWorks database, sorted by Vendor ID and Employee ID. This is the data that will be used in this report.

Below is a screenshot of an Excel template with data markers that will be populated with the data from the above query.

After running the report, the imported data looks like this:

Creating a PivotTable

  1. On a sheet, different than the sheet with the data markers, select the cell where you would like to insert the pivot table.

  2. Go to Insert > PivotTable on the Excel ribbon



  3. When prompted to select data, navigate to the sheet with the data markers. Select the header row and the data marker row. Click OK when finished.



  4. This will insert a blank PivotTable into the second worksheet.



  5. Drag VendorName into the Row Labels section and EmployeeID into the Column Labels section. Drag TotalDue into the Values section.



  6. In the Excel ribbon, go to Design and select a style to apply to the PivotTable.



You've added a PivotTable to your report, but there are a few settings that need to be changed before we're done.

Field Settings and PivotTable Options

Field Settings

  1. You will note that the formula used to aggregate the TotalDue field is currently set to Count. This is because the only data in the data source is a data marker, which is a string. Right click the TotalDue field and select Value Field Settings.



  2. Switch the summarize formula to be Sum instead of Count. Click OK when finished.

PivotTable Options

  1. Right click on the PivotTable go select PivotTable Options



  2. Go to the Data tab.

  3. To make sure that the new imported data is pulled into the PivotTable when you open the rendered report, you have to set the PivotTable to Refresh data when opening the file.

    If you don't do this, your PivotTable will look exactly the same as it does in the template until the PivotTable is refreshed.



  4. Under the Retain items deleted from the data source you will see a Number of items to retain per field drop-down. Select None from the dropdown.

    If you don't, the data markers that are currently in your data source will be carried over to the output file. The data markers will appear in the PivotTable label filters.



  5. Click OK when finished.

You are now done setting up the PivotTable in your report template.

Viewing the PivotTable

Deploy, and View your report.

Icon

When using the OfficeWriter Designer View functionality, you may be prompted to re-deploy your report even if you have not made changes since the report was last deployed or retrieved. This is because when the report is opened or deployed, Excel considers this a workbook open event, so the PivotTable refreshes.

Although there are no visible changes to the report, Excel treats the refreshed PivotTable as a change to the file. Any time Excel detects changes to the file, it will prompt you to redeploy the report before viewing in the Designer.

Notice that on the first sheet, your data columns display the correct data.

Now look at the sheet containing your PivotTable. You should find the EmployeeID numbers across the top and all the vendor names along the left column. Each cell will contain the sum for each vendor/employee combination.

Click on the down arrow next to the Vendor Name label. Clear Show All and just select a few vendors.

Do the same for the EmployeeID field.

Now look at your results.

Viewing the Report in Reporting Services Report Manager

In your browser, type the path to the Report Manager (Usually http://<YourReportServer>/Reports). Navigate to the report and view it.

To see the report as you designed it with OfficeWriter:

  1. From the export option drop-down list, choose Excel designed by Officewriter.

  2. You will be prompted to save or open the output file. If your report contains a PivotTable AND you are using Internet Explorer 8 or earlier, you MUST select Save. After it saves to disk, then you may select Open to view it.

This is because of an issue with how Internet Explorer caches temporary internet files. If you are using any other browser or Internet Explorer 9 or later, this issue does not occur and you can open the file directly.

  • No labels