Add Data by Using a Custom Query (Tutorial)

Looking for help with Power Pivot in Excel 2013? Go to Power Pivot Help on

In this task, you will connect to a Microsoft Access database and use a custom query to import data into your PowerPivot workbook. An Access database is a relational data source. PowerPivot can import data from a variety of relational sources: SQL Server, Oracle, Sybase, Informix, DB2, Teradata, and more.

Importing data from the Access database involves connecting to the database, locating the query file, and running the query to import the data into your PowerPivot workbook.

Keep in mind that in order to use this data in your analysis, you will have to create relationships between the data from the Access database and the other data in your PowerPivot workbook. Instructions for creating relationships are provided in a later lesson. For more information, see Create Relationships Between Tables (Tutorial).


This topic is part of a PowerPivot for Excel tutorial, which should be completed in order. For information about prerequisites and the first step in the tutorial, see PowerPivot for Excel Tutorial Introduction.

To create a connection to an Access database

  1. In the PowerPivot window, on the Home tab, click From Database, and then click From Access. The Table Import Wizard appears and guides you through setting up a connection to a data source.

  2. In the Friendly connection name box, type Product Category Access DB.

  3. To the right of the Database name box, click Browse. Navigate to the location where you downloaded the sample files, select ProductCategories, and then click Open.

  4. Click Next.

Use a Query to Select the Data to Import

The procedure for using the Table Import Wizard to import by selecting from a list of tables was described in the previous lesson in this tutorial. So instead of duplicating those steps, you will use a custom query to import this set of Access data.

The Table Import wizard guides you through the steps. You can either import a query, copy and paste the text of an existing query, or write a new query by using the PowerPivot graphical query builder. In this lesson, you will import a query that you received from the IT department.

To use the query designer tool to select the data to import

  1. Select the Write a query that will specify the data to import option, and then click Next.

  2. In the Friendly Query Name box, type Product Category Query.

  3. Click Design to open the Query Builder dialog box.

  4. Click Import, and then navigate to the location on your computer where you saved the samples.

  5. If you do not see the file listed, click the file down arrow, and then select All files (*.*).

  6. Select SQLQuery, and then click Open.

    The SQL statement appears in the window. This query selects all data from the ProductCategory table except GAMES and TOYS and HOME APPLIANCES.

  7. Click OK, Validate, and then Finish. A summary of the columns you are importing appears.

  8. When the import is finished, click Close.

    The data is displayed as a new table named Query in your PowerPivot workbook. You can keep this data current by refreshing. If the contents of the Access database change, refreshing keeps your PowerPivot data up-to-date. For more information, see Different Ways to Update Data in PowerPivot.

  9. Rename the new table by right-clicking the Query tab and selecting Rename. Type ProductCategory and then click Enter. If a message dialog box opens, click OK.

Next Step

To continue this tutorial, go to the next topic: Add Data by Using Copy and Paste (Tutorial).

See Also


Recalculate Formulas

Import Data from a Database

Other Resources

Relationships Between Tables

Add and Maintain Data in PowerPivot