If you use Excel PivotTables then you’re probably familiar with the need to consolidate data from multiple tables into a single table before you can Pivot it.

One way to do this is using VLOOKUP or INDEX & MATCH formulas to bring columns from one table into another.

However, in Excel 2010 onwards we have Power Pivot*, which means we no longer have to flatten or consolidate our tables. Instead we simply create a relationship between the tables and this enables us to create a *Power Pivot PivotTable* using columns from multiple tables.

**Power Pivot is available in Excel 2010 or Excel 2013/2016 Office Professional Plus, Office 365 Professional Plus, or in the standalone edition of Excel 2013/2016.*

As always, an example will help.

## Download the Workbook

Download the Excel 2013+ Workbook

Note: these are .xlsx files please ensure your browser doesn't change the file extension on download.

## The Data

I’ve got two Excel tables [image 1], one for my transactional data (called ‘data’). If you’re familiar with databases, then this is often called a fact table. The other table is a list of my Products and their respective categories (called ‘categories’); this is the table you’d normally lookup to find the category for each product.

In the pre-Power Pivot days I’d use an INDEX & MATCH formula to bring the Category information into my Data table, but no more.

## Power Pivot does VLOOKUP

Let’s look at how we can get our data into Power Pivot, create a relationship between the two tables and then analyse the data in a single PivotTable.

- Make sure your data is formatted in an Excel table (CTRL+T). Mine are called ‘data’ and ‘categories’.
**Tip 1:**It’s a good idea to rename your tables from the default of ‘Table1’, ‘Table2’ etc. as this name will also be used in Power Pivot.**Tip 2:**Your lookup table must not have any duplicate values for the Product column. Makes sense since Power Pivot wouldn’t know which record to choose if there was more than one.

- With any cell in your table selected, go to the Power Pivot tab > Add to Data Model (Excel 2013/2016) /Create Linked Table (Excel 2010) [image 2]:

This will open the Power Pivot window [image 3] and you can see your data table. It looks a lot like Excel with a formula bar, rows and columns and a ribbon with tabs etc.:

- Repeat for all tables.
**Tip**: notice the name of the tables in Power Pivot is the same as the Excel Table names. In my example they are ‘data’ and ‘categories’.

- Next we need to create the relationship between the two tables.

If you’re familiar with VLOOKUP then you can think of it in the same way. For example, using VLOOKUP we’d add a column to the ‘data’ table that looks up the Product name from the data table, finds the matching name in the categories table and returns the category for that product (we’ll ignore the fact that we'd have to change the categories table column order to Product, then Category, for VLOOKUP to actually work, but you get the idea.

In Power Pivot we simply tell it which table is doing the looking up, which the table is being looked up and which are the matching columns from both tables. Power Pivot doesn’t care what order your columns are in.

To set up the relationship go to the Power Pivot window > Design tab > Create Relationship [image 4].

**(a)**‘Table’ is the one containing our transactional data, which is called ‘data’.**(b)**‘Related Lookup Table’ is the table we’re looking up, just as you would with a VLOOKUP formula. In this example it’s the ‘categories’ table.**(c)**‘Column’ and ‘Related Lookup Column’ are the matching (related) columns from each table. In this example, the Product columns.*Remember: the Product column in the ‘Related Lookup Table’ cannot contain duplicate values in.*

## Grouping Dates in Power Pivot

One thing I’d like to be able to do is group my data by month. In Power Pivot for Excel 2010 and 2013 there is no Group functionality like we have in regular PivotTables. There is in Excel 2016 but I’m using Excel 2013, so, we can do this one of two ways;

- Add a 'date' table to our model for date classifications, then create a relationship between the ‘data’ table and the ‘date’ table. This is the preferred method as it results in a smaller file because there is typically less data.
- Add columns to our source data that classifies the dates into their month/year etc. I’m going to do that for this example to keep it simple, and because the Date table isn’t the focus of this tutorial.

## Adding Columns in Power Pivot

Adding a column for the month name is much like Excel.

In Power Pivot we have similar functions to Excel and they have similar syntax structure. For the Month name I’m going to use the FORMAT function to extract the month name from the Date column. In Excel we would use the TEXT function to do the same thing.

- To add a column click in a cell in the ‘Add Column’ column of the ‘data’ table, or click on the ‘Add Column’ column header.
- In the formula bar type your formula [see image 5].
- Then press ENTER to complete it.

- Double click the column header of your new column and give it a new name. I’ll call mine ‘Month’ [image 6].

## Set ‘Sort by Column’ Rules

The month names we’ve just added are text, so when we use them in the Power Pivot PivotTable they will be sorted alphabetically instead of in month order. We can override this by telling Power Pivot to sort the month names based on the month number, but we need a column containing the month number first.

We’ll add another column and use the MONTH function (just like in Excel) to extract the month number from the Date column [image 7].

With the Month column selected go to the Home tab > Sort by Column [image 8]:

In the ‘Sort by Column’ dialog box [image 9] the Sort Column should already show ‘Month’ because you selected it before clicking ‘Sort by Column’. In the By Column choose ‘MonthNumber’:

## Inserting a Power Pivot PivotTable

Now that we have our relationship set up and the extra columns for our month name and sorting rules we can insert a PivotTable. Power Pivot PivotTables are created from the Power Pivot window.

- In the Power Pivot window > Home tab > PivotTable [image 10]:

- In the Create PivotTable dialog box choose where you want to put the PivotTable; New or existing worksheet.
- You should see both of your tables in the Field list. Clicking on the triangle (Excel 2013/2016) or + sign (Excel 2010) beside each table name will reveal the fields, and can go ahead and build your PivotTable using fields from both tables.

## Step by Step Video

Wow, it seems like a lot of steps to replicate a VLOOKUP in Power Pivot but it’s actually not that involved. I’ve recorded a 2 minute video (no sound) so you can see how easy it is.

## More on Power Pivot

- Get the free Power Pivot add-in
- Learn Power Pivot
- Learn Excel PivotTables - this is a must before learning Power Pivot.

## Please Share

If you liked this or know someone who could use it please click the buttons below to share it with your friends on LinkedIn, Google+, Facebook and Twitter.

Theresa Diers says

Do you know if the free Power Pivot add-in is available with Excel 2010 Office 365 Personal? I’m having trouble with the download.

Thank you,

Theresa

Mynda Treacy says

Yes it should be. Are you having trouble downloading it or installing it?

Cathy says

Great work as always! Love sorting by the month number, how would I sort in order of financial year month eg July = 1, August = 2 etc?

Mynda Treacy says

Hi Cathy,

You’d have to add a column for the financial year month. e.g. you could use this formula:

Mynda

Cathy says

That’ll work, thanks!

Alissa Wright says

Thanks for this! I had a formatting question: How could I highlight, for each month, the category with the highest sales, so that visually it would stand out?

Catalin Bombea says

Hi Alissa,

The best way is to create a pivot table, with Months and Categories in the Rows field, and Sales Values in Values field. Then you can sort the Category field of the pivot table, descending, based on Values (not the Sort A-Z option, choose More Options in filter menu.)

You can also apply a Top 10 filter (Or Top 1, Top 3, if you want only the highest values)

The pivot table is more appropriate for large number of records/categories. You can add a pivot chart, if there is a small number of categories. Even if you use a pivot chart, a top 3 filter can be applied, to reduce the number of items displayed in the chart.

Catalin

Jay Frantz says

Mynda…does this work in Excel 2016 (Office 365) on a Mac?

Catalin Bombea says

Hi Jay,

Unfortunately, Power Pivot is not supported on a Mac…

Catalin

Jean says

Love the way you make doing this so clear. Saving this one for future reference!

Mynda Treacy says

Thanks, Jean! Glad you’ll find this useful.