Learn Excel Power Pivot
Learn Excel Power Pivot
Pivot Tutorial
Excel Power Pivot is an efficient, powerful tool that comes
with Excel as an Add-in. With Power Pivot, you can load
hundreds of millions of rows of data from external sources
and manage the data effectively with its powerful xVelocity
engine in a highly compressed form. This makes it possible
to perform the calculations, analyze the data, and arrive at a
report to draw conclusions and decisions.
FREE EBOOKs
Thank you!
TABLE OF CONTENTS
HIERARCHIES
You can define data hierarchies in a data table so that it
would be easy to handle related data fields together in
Power PivotTables. You will learn the details of the creation
and usage of Hierarchies in the chapter − Hierarchies in
Power Pivot.
AESTHETIC REPORTS
You can create aesthetic reports of your data analysis with
Power Pivot Charts and/or Power Pivot Charts. You have
several formatting options available to highlight the
significant data in the reports. The reports are interactive in
nature, enabling the person looking at the compact report to
view any of the required details quickly and easily.
• Click Add-Ins.
• In the Manage box, select COM Add-ins from the
dropdown list.
• Click the Go button. The COM Add-Ins dialog box
appears.
• Check Power Pivot and click OK.
The data that you work on in Excel and in the Power Pivot
window is stored in an analytical database inside the Excel
workbook, and a powerful local engine loads, queries, and
updates the data in that database. Since the data is in Excel,
it is immediately available to PivotTables, PivotCharts,
Power View, and other features in Excel that you use to
aggregate and interact with the data. The data presentation
and interactivity is provided by Excel and the data and Excel
presentation objects are contained within the same
workbook file. Power Pivot supports files up to 2GB in size
and enables you to work with up to 4GB of data in memory.
You need not have the data in Excel tables when you are
importing data from external sources. If you have data as
Excel tables in the workbook, you can add them to Data
Model, creating data tables in Data Model that are linked to
the Excel tables.
DATA MODEL
The Data Model is the most powerful feature of Power
Pivot. The data that is obtained from various data sources is
maintained in Data Model as data tables. You can create
relationships between the data tables so that you can
combine the data in the tables for analysis and reporting.
You will learn in detail about the Data Model in the chapter
− Understanding Data Model (Power Pivot Database).
MEMORY OPTIMIZATION
Power Pivot Data Model uses xVelocity storage, which is
highly compressed when data is loaded into memory that
makes it possible to store hundreds of millions of rows in
memory.
Thus, if you load data directly into Data Model, you will be
doing it in the efficient highly compressed form.
POWER PIVOTTABLES
You can create the Power PivotTables from Power Pivot
window. The PivotTables so created are based on the data
tables in the Data Model, making it possible to combine data
from the related tables for analysis and reporting.
POWER PIVOTCHARTS
You can create the Power PivotCharts from Power Pivot
window. The PivotCharts so created are based on the data
tables in the Data Model, making it possible to combine data
from the related tables for analysis and reporting. The Power
PivotCharts have all the features of Excel PivotCharts and
many more such as field buttons.
DAX LANGUAGE
The strength of Power Pivot comes from the DAX Language
that can be used effectively on the Data Model to perform
calculations on the data in the data tables. You can have
Calculated Columns and Calculated Fields defined by DAX
that can be used in the Power PivotTables and Power
PivotCharts.
If you want the data for Power Pivot, do it the second way,
without Excel even knowing about it. This is because you
will be loading the data only once, in highly compressed
format. To understand the magnitude of difference, suppose
you load data into Excel by first adding it to the Data Model,
the file size is say 10 MB.
If you load data into PowerPivot, and hence into Data Model
skipping the extra step of Excel, your file size could be as
less as 1 MB only.
• Click OK.
• Click the Select Related Tables button.
• Power Pivot checks what other tables are related to
the selected Medals table, if a relation exists.
You can see that Power Pivot found that the table
Disciplines are related to the table Medals and selected it.
Click Finish.
Note that the Table Import Wizard options change as per the
data source that is selected to connect to. You might want to
know what data sources you can choose from.
Select the tables that you want to import and click Finish.
The selected five tables will be imported. Click Close.
You can see that the five tables are added to the Power
Pivot, each in a new tab.
CREATING LINKED TABLES
Linked tables are a live link between the table in Excel and
the table in the Data Model. Updates to the table in Excel
automatically update the data in the data table in the model.
You can link the Excel table into Power Pivot in a few steps
as follows −
Once your data in the workbook is ready, you can import the
data as follows −
If you want to load a csv file into Power Pivot, you have to
use the Text File option. Suppose you have the following
text file with csv format −
• Click the PowerPivot tab.
• Click the Home tab in the PowerPivot window.
• Click From Other Sources in the Get External Data
group. The Table Import Wizard appears.
• Scroll down to Text Files.
• Click Text File.
• Click the Next → button. Table Import Wizard
appears with the display − Connect to Flat File.
• Browse to the text file in the File Path box. The csv
files usually have the first line representing column
headers.
• Check the box Use first row as column headers, if
the first line has headers.
• In the Column Separator box, default is Comma (,),
but in case your text file has any other operator such
as Tab, Semicolon, Space, Colon or Vertical Bar,
then choose that operator.
As you can observe, there is a preview of your data table.
Click Finish.
• Copy the data to an Excel file and use the Excel file
as data source for Power Pivot.
• Copy the data, so that it will be on the clipboard, and
paste it into Power Pivot.
The data copied into the clipboard will be pasted into a new
data table in Power Pivot, with the tab − Word-Employee
table.
Suppose, you want to replace this table with new content.
Click OK.
As you can observe, the contents of the data table in Power
Pivot are replaced by the contents in the clipboard.
Click OK to proceed.
If you want to refresh all the data tables in the Power Pivot,
do the following −
In fact, you can manage the Data Model from Power Pivot
window. You can add data to Data Model, import data from
different data sources, view the Data Model, create
relationships between the tables, create calculated fields and
calculated columns, etc.
A data table on the other hand coexists with other data tables
with relationships, facilitating the combination of data from
multiple tables. Data tables get created when you import
data into Power Pivot. You can also add Excel tables to the
Data Model while you are creating a Pivot Table getting
external data or from multiple tables.
• Data View.
• Diagram View.
DATA VIEW OF DATA MODEL
In the data view of the Data Model, each data table exists on
a separate tab. The data table rows are the records and
columns represent the fields. The tabs contain the table
names and the column headers are the fields in that table.
You can do calculations in the data view using the Data
Analysis Expressions (DAX) language.
You can analyze data from across multiple tables only when
relationships exist among them. With Power Pivot, you can
create relationships from the Data View or Diagram View.
Moreover, if you had chosen to add a table to the Power
Pivot, you need to add a relationship as well.
You have added the Sales table data to the Data Model.
Next, you have to get the Salesperson table data also into
Data Model as follows −
You can see that the box – Add this data to the Data
Model is checked and inactive. Click OK.
The PivotTable will be created.
As you can observe the two tables are in the Data Model.
You might have to create a relationship between the two
tables as in the previous section.
You can add these Excel tables to the Data Model first,
before doing any analysis.
You can find that the names of the two tables present in
your workbook are displayed and the name Salesperson is
ticked. This means the data table Salesperson is linked to the
Excel table Salesperson.
Click Go to Excel Table.
TO EDIT A RELATIONSHIP
• Click on a Relationship.
• Click the Edit button. The Edit Relationship dialog
box appears.
• Make the required changes in the relationship.
• Click OK. The changes get reflected in the
relationship.
TO DELETE A RELATIONSHIP
• Click on a Relationship.
• Click on the Delete button. A warning message
appears showing how the tables that are affected by
deleting the relationship would affect the reports.
• Click OK if you are sure you want to delete. The
selected relationship is deleted.
Again, click the ACTIVE tab. Both the tables − Sales and
Salesperson appear under the ACTIVE tab.
You will learn the two simple calculations that exist in Data
Model − Calculated Column and Calculated Field in this
chapter.
CALCULATED COLUMN
Calculated column is a column in the Data Model that is
defined by a calculation and that extends the content of a
data table. It can be visualized as a new column in an Excel
table defined by a formula.
The column on the right side with the header − Add Column
is highlighted.
Type = [Product Price] * [No. of Units] in the formula bar
and press Enter.
A new column with header CalculatedColumn1 is inserted
with the values calculated by the formula you entered.
• Double click the header of the new calculated
column.
• Rename the header as TotalProductPrice.
Repeat the above given steps for the South Sales data table
and West Sales data table.
You have the necessary columns to summarize the Gross
Profit. Now, create the Power PivotTable.
All the imported tables that are a part of Power Pivot Data
Model appear in the PivotTable Fields list.
• Drag the NOC_CountryRegion field in the Medals
table to the COLUMNS area.
• Drag Discipline from the Disciplines table to the
ROWS area.
• Filter Discipline to display only five sports: Archery,
Diving, Fencing, Figure Skating, and Speed Skating.
This can be done either in PivotTable Fields area, or
from the Row Labels filter in the PivotTable itself.
• Drag Medal from the Medals table to the VALUES
area.
• Select Medal from the Medals table again and drag it
into the FILTERS area.
CREATING A PIVOTTABLE
You can create a Power PivotTable as follows −
As you can observe, though the rows with empty values are
not displayed, the information on the Salesperson also got
hidden.
CREATING A PIVOTCHART
Suppose you want to create a PivotChart based on the
following Data Model.
Two field buttons for the two selected fields appear on the
PivotChart. These are the Axis field buttons. The use of
field buttons is to filter data that is displayed on the
PivotChart.
Drag TotalSalesAmount from each of the four tables–
East_Sales, North_Sales, South_Sales and West_Sales to ∑
VALUES area.
• AXIS (Categories)
• LEGEND (Series)
• ∑ VALUES
• FILTERS
FILTERS IN PIVOTCHART
You can use the Axis field buttons on the chart to filter the
data being displayed. Click on the arrow on the Axis field
button – Region.
SLICERS IN PIVOTCHART
Using Slicers is another option to filter data in the Power
PivotChart.
PIVOTCHART TOOLS
In Power PivotChart, the PIVOTCHART TOOLS has three
tabs on the Ribbon as against two tabs in Excel PivotChart −
• ANALYZE
• DESIGN
• FORMAT
The options on the Ribbon under FORMAT tab are all for
adding splendor to your PivotChart. You can use these
options judiciously, without getting over bored.
In this chapter, you will learn how to create the Table and
Chart combinations from within the Power Pivot window.
Consider the following Data Model in Power Pivot that we
will use for illustrations −
As you can see, USA has the highest number of Medals (>
4500).
• Click on the PivotTable.
• Drag Sport from the Sports table to the ROWS area.
• Drag Medal from the Medals table to the ∑
VALUES area.
• Drag NOC_CountryRegion from Medals table to
FILTERS area.
• Filter the NOC_CountryRegion field to the value
USA.
RENAMING A HIERARCHY
To rename the hierarchy field, do the following −
Drag the fields Year and Season, in that order to the new
hierarchy. The hierarchy shows the child levels.
• Select USA.
• Drag Gender from Medals table to GENDER area.
• Click PivotChart.
• Drag Discipline from Disciplines table to AXIS area.
• Drag Medal from Medals table to ∑ VALUES area.
• Click PivotTable.
• Drag Discipline from Disciplines table to ROWS
area.
• Drag Medal from Medals table to ∑ VALUES area.
• Click the ANALYZE tab in PIVOTTABLE TOOLS
on the Ribbon.
• Click Insert Slicer. The Insert Slicers dialog box
appears.
• Click on NOC_CountryRegion and Sport in Medals
table.
• Click OK.
You can see that all the PivotTables and PivotCharts in the
workbook are listed in the dialog box.
Thank you!