Locked lesson.
About this lesson
Got multiple datasets stored in different worksheets or workbooks that you want to analyze in one Pivot Table? If so, Power Pivot is your savior.
Exercise files
Download this lesson’s related exercise files.
06-04-Combine Data Sources with PowerPivot-Part1-Start.xlsx319.6 KB 06-04-Combine Data Sources with PowerPivot-Part1-Complete.xlsx
241.8 KB 6.04 combine-multiple-data-sources-with-power-pivot - Exercise.docx
52.9 KB Exercise - Combine Multiple Data Sources.xlsx
82.6 KB 6.04 combine-multiple-data-sources-with-power-pivot - Exercise solution.docx
135.4 KB Exercise Solution - Combine Multiple Data Sources.xlsx
441.1 KB transactions_2019.xlsx
21.6 KB transactions_2020.xlsx
21 KB transactions_2021.xlsx
21 KB Transaction_Analysis.xlsx
254.6 KB
Quick reference
Combine Multiple Data Sources with Power Pivot and Power Query
Learn how to create a PivotTable that uses data from multiple sources.
When to use
We create a PivotTable using Power Pivot and Power Query whenever we have data stored in different sources.
Instructions
In general, when creating a PivotTable, our data is stored in one place. The data source is usually stored on a worksheet and we create a PivotTable based on the data source.
However, what if we have multiple tables of data that we want to combine into one PivotTable? That is where Power Pivot and Power Query can help.
Power Pivot is a utility in Excel that allows us to select multiple data sources and create relationships between the different data tables. We can use Power Query to combine files together and tidy up the data.
Turn on the Power Pivot Ribbon
- Click on File.
- Click Options.
- Go to the Customize Ribbon page.
- In the list on the right-hand side, put a check next to Power Pivot.
Combine Files and Link to a Folder
In our example, we want to build a Pivot Table that uses data from two transaction files, 'transactions_2019.xlsx' and 'transactions.2020.xlsx' that we have stored in a folder called 'Transaction_Data'.
These files both contain the same column headings just different sales values. We can combine both of these files into one long file using Power Query.
We can also set up a link to the 'Transaction_Data' folder so that when the 2021 file is added at the end of the year, all PivotTables and Pivot Charts automatically update to include the new data.
- From the Data tab, in the Get & Transform Data group, click Get Data, From File, and then From Folder.
- Select the folder 'Transaction_Data'.
- Click Open.
- From the menu at the bottom, click Combine and then Combine & Transform Data.
- Select 'Sheet1' to see a preview of the combined files.
- Click OK.
The combined files will now open in the Power Query Editor.
Tidy Data with Power Query
We can use Power Query to clean our dataset and prepare it for analysis in the PivotTable.
We will not do a deep dive into Power Query but we will change a couple of things.
For example, the first column titled 'Source.Name' shows us the file name for each record. We don't need this in our analysis.
- Click in the Source.Name column.
- Right-click and select Remove.
It's also worth checking that the correct data type has been selected for each column.
- Click the icon to the left of the column heading.
- Change the data type where required.
Load into Excel
Once we have finished tidying our data in Power Query, we can load it back into Excel.
- From the Home tab (in Power Query), in the Close group, click Close & Load.
This will load the data back into Excel and format it as an Excel table.
Login to download
Lesson notes are only available for subscribers.