Monday, January 21, 2019

Create a PivotTable with an external data source

Create a PivotTable with an external data source

Being able to analyze all the data can help you make better business decisions. But sometimes it's hard to know where to start, especially when you have a lot of data that is stored outside of Excel, like in a Microsoft Access or Microsoft SQL Server database, or in an Online Analytical Processing (OLAP) cube file. In that case, you'll connect to the external data source, and then create a PivotTable to summarize, analyze, explore, and present that data.

Here's how to create a PivotTable by using an existing external data connection:

  1. Click any cell on the worksheet.

  2. Click Insert > PivotTable.

    PivotTable button on the Insert tab

  3. In the Create PivotTable dialog box, under Choose the data that you want to analyze, click Use an external data source.

    Create PivotTable dialog box with Use an external data source selected

  4. Click Choose Connection.

  5. On the Connections tab, in the Show box, keep All Connections selected, or pick the connection category that has the data source you want to connect to.

To reuse or share an existing connection, use a connection from Connections in this Workbook.

  1. In the list of connections, select the connection you want, and then click Open.

  2. Under Choose where you want the PivotTable report to be placed, pick a location.

    • To place the PivotTable in a new worksheet starting at cell A1, choose New Worksheet.

    • To place the PivotTable in the active worksheet, choose Existing Worksheet, and then in the Location box, enter the cell where you want the PivotTable to start.

  3. Click OK.

    Excel adds an empty PivotTable and shows the Field List so that you can show the fields you want and rearrange them to create your own layout.

    Field List showing external data fields

  4. In the field list section, check the box next to a field name to place the field in a default area of the areas section of the Field List.

    Typically, nonnumeric fields are added to the Rows area, numeric fields are added to the Values area, and date and time fields are added to the Columns area. You can move fields to a different area as needed.

    Tip:  You can also right-click a field name, and then select Add to Report Filter, Add to Column Labels, Add to Row Labels, or Add to Values to place the field in that area of the areas section, or drag a field from the field section to an area in the areas section.

    Use the Field List to further rearrange the PivotTable data by right-clicking the fields in the areas section, and then selecting the area you want, or by dragging the fields between the areas in the areas section.

Connect to a new external data source

To create a new external data connection to SQL Server and import data into Excel as a table or PivotTable, do the following:

  1. Click Data > From Other Sources.

From Other Sources button on the Data tab

  1. Click the connection you want.

    • Click From SQL Server to create a connection to a SQL Server table.

    • Click From Analysis Services to create a connection to a SQL Server Analysis cube.

  2. In the Data Connection Wizard, complete the steps to establish the connection.

    • On page 1, enter the database server and specify how you want to log on to the server.

    • On page 2, enter the database, table, or query that contains the data you want.

    • On page 3, enter the connection file you want to create.

To create a new connection to an Access database and import data into Excel as a table or PivotTable, do the following:

  1. Click Data > From Access.

From Access button on the Data tab

  1. In the Select Data Source dialog box, locate the database you want to connect to, and click Open.

  2. In the Select Table dialog box, select the table you want and then click OK.

If there are multiple tables, check the Enable selection of multiple tables box so you can check the boxes of the tables you want, and then click OK.

  1. In the Import Data dialog box, select how you want to view the data in your workbook and where you want to put it, and then click OK.

The tables are automatically added to the Data Model, and the Access database is added to your workbook connections.

More information about PivotTables

No comments:

Post a Comment