Applies ToExcel for Microsoft 365 Excel 2024 Excel 2021 Excel 2019 Excel 2016

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.

    Insert PivotTable dropdown showing "from Power BI" option.

  3. In the Create PivotTable dialog box, click From External Data Source.

    PivotTable from External Source

  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 design the layout and format of a PivotTable 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

  2. 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.

  3. 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

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

  3. 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.

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

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.