Background

PivotCharts and PivotTables are similar in that they both allow you to manipulate how your data is presented and analyzed. PivotTables can be the foundation of PivotCharts. If you are not familiar with PivotTables, see Working with PivotTables first. PivotCharts are a useful way to visualize data that appears in PivotTables.

Let's take a look at how to add a PivotChart (and PivotTable) to a Excel report for OfficeWriter.

Setup

This example will use the AdventureWorks sample database shipped with SQL Server Reporting Services. We assume you already know how to create a basic report in Excel using Officewriter Designer. If you don't know how to do this, first read Quick Start.

This query returns employee pay rate and department data from the AdventureWorks database. This is the data that will be used in the report.

SELECT Gender, Title, Employee.EmployeeID, Rate, Department.GroupName
FROM AdventureWorks.HumanResources.Employee,
	AdventureWorks.HumanResources.Department,
	AdventureWorks.HumanResources.EmployeeDepartmentHistory,
	AdventureWorks.HumanResources.EmployeePayHistory
WHERE Employee.EmployeeID = EmployeePayHistory.EmployeeID AND
	Employee.EmployeeID = EmployeeDepartmentHistory.EmployeeID AND
	Department.DepartmentID = EmployeeDepartmentHistory.DepartmentID

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

Creating a PivotChart

  1. On a sheet, different than the sheet with the data markers, select the cell where you would like to place the PivotTable for the PivotChart. A PivotChart is powered by an underlying PivotTable, so you will need to create a PivotTable at the same time as the PivotChart.

  2. Go to Insert > Pivot Chart on the Excel ribbon.



  3. This will insert a blank PivotChart and PivotTable into the worksheet. You may notice that the labels in the Pivot Fields box have changed to reflect that we are designing for a PivotChart (e.g. Row labels >> Axis labels)



  4. Drag the Department pivot field into the Report Filter section. Drag Title into Axis Fields, Gender into Legend Fields, and Base Rate into Values. When you are done you should have a PivotChart that looks like this:



  5. The default PivotChart type is a basic column chart. To change the chart type, select the PivotChart and then go to Change Chart Type in the PivotChart tools ribbon (which is available when a PivotChart is selected).



  6. Let's change the chart type to 3D Clustered Column.



Now that you have a basic PivotChart in your report, you will need to make some changes to the field settings and PivotTable options before the template is finished.

Field Settings

Just as we did for the PivotTable in Working with PivotTables, we will want to change the Values computation from Count to something more useful.

Right click on Count of Base Rate in the Values section in the Pivot Fields menu and switch the calculation to Average.

Refreshing the Data

We mentioned earlier that PivotCharts are powered by underlying PivotTables. To make sure that the new data is pulled into the PivotTable (and therefore the PivotChart), the data source needs to refresh when the workbook opens.

  1. Right click the PivotTable or PivotChart and select PivotTable Options from the drop-down.

  2. Go to the Data tab

  3. Check off Refresh data when opening the file

  4. To avoid pulling the data markers into the filters of the final report, select None from the Number of items to retain per field dropdown.



  5. Click OK when you are finished.

Your PivotChart is now finished and should look like this:

Viewing the PivotChart

Deploy, and View your report.

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.

Look at the sheet containing your PivotChart and PivotTable. You should have the Titles across the bottom of the graph but it is not very pretty. It contains all the data.

Open the drop-down list of departments and select one to filter the PivotChart display.

Now you get a clear graphical picture of the data that visually presents the wage differences between males and females by position across departments.

You'll also notice that the PivotTable has been filtered too. Since the PivotChart displays the data that is in the PivotTable, when you change the view in the PivotChart, the PivotTable updates accordingly as well.

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. If your report contains a PivotTable/PivotChart 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.