Pivot Table
Pivot Table
A pivot table is a data processing tool commonly used in spreadsheet applications like Microsoft
Excel and Google Sheets. It allows users to summarize, analyze, and reorganize large datasets
efficiently.
Group and summarize data: Aggregate data based on categories (e.g., totals, averages).
Filter and sort: Focus on specific subsets of data.
Create dynamic reports: Rearrange rows and columns to see different perspectives of
the data.
Visualize trends: Easily spot patterns and insights.
Pivot tables are especially useful for tasks like sales reporting, budgeting, and any scenario
where you need to analyze large amounts of data quickly.
Or
A Pivot table is a summary of your data package. The word ‘Pivot‘in the Pivot
table means to rotate the data in Excel to view it from a different
perspective. Creating a Pivot table doesn’t mean adding, subtracting,
or changing the data, it simply means reorganizing it so you can easily work with
useful information.
For example, a store owner might list monthly sales totals for a large number of
merchandise items in an Excel spreadsheet. If they wanted to know which items
sold better in a particular financial quarter, they could use a pivot table.
Let’s say we have a worksheet that contains monthly sales data for three different
products — product 1, product 2, and product 3. You want to figure out which of
the three has been generating the most revenue.
One way would be to look through the worksheet and manually add the
corresponding sales figure to a running total every time product 1 appears.
The same process can then be done for product 2 and product 3 until you have
totals for all of them. Piece of cake, right?
Imagine, now, that your monthly sales worksheet has thousands upon thousands of
rows. Manually sorting through each necessary piece of data could literally take a
lifetime.
With pivot tables, you can automatically aggregate all of the sales figures for
product 1, product 2, and product 3 and calculate their respective sums in less than
a minute.
Pivot tables inherently show the totals of each row or column when created. That’s
not the only figure you can automatically produce, however.
Let’s say you entered quarterly sales numbers for three separate products into an
Excel sheet and turned this data into a pivot table.
The pivot table automatically gives you three totals at the bottom of each column
having added up each product’s quarterly sales.
But what if you wanted to find the percentage these product sales contributed to all
company sales, rather than just those products’ sales totals?
With a pivot table, instead of just the column total, you can configure each column
to give you the column’s percentage of all three column totals.
Let’s say three products totaled $200,000 in sales, and the first product made
$45,000. You can edit a pivot table to say this product contributed 22.5% of all
company sales.
To show product sales as percentages of total sales in a pivot table, simply right-
click the cell carrying a sales total and select Show Values As > % of Grand
Total.
In this scenario, you’ve just completed a blog redesign and had to update many
URLs. Unfortunately, your blog reporting software didn’t handle the change well
and split the “view” metrics for single posts between two different URLs.
In your spreadsheet, you now have two separate instances of each individual blog
post. To get accurate data, you need to combine the view totals for each of these
duplicates.
"Instead of having to manually search for and combine all the metrics from the
duplicates, you can summarize your data (via pivot table) by blog post title.
Pivot tables are helpful for automatically calculating things that you can’t easily
find in a basic Excel table. One of those things is counting rows that all have
something in common.
For instance, let’s say you have a list of employees in an Excel sheet. Next to the
employees’ names are the respective departments they belong to.
You can create a pivot table from this data that shows you each department’s name
and the number of employees that belong to those departments.
The pivot table’s automated functions effectively eliminate your task of sorting the
Excel sheet by department name and counting each row manually.
5. Adding Default Values to Empty Cells: Not every dataset you enter into Excel
will populate every cell. If you’re waiting for new data to come in, you might have
lots of empty cells that look confusing or need further explanation. That’s where
pivot tables come in.
"You can easily customize a pivot table to fill empty cells with a default value,
such as $0 or TBD (for “to be determined”).For large data tables, being able to tag
these cells quickly is a valuable feature when many people are reviewing the same
sheet. To automatically format the empty cells of your pivot table, right-click your
table and click PivotTable Options. In the window that appears, check the box
labeled “For Empty Cells Show” and enter what you’d like displayed when a cell
has no other value.
How to Create a Pivot Table in Excel
Creating a pivot table in Excel is easy and provides immense value. Here’s a
simple guide:
Step 1: Open MS Excel and Select the Data
Open your worksheet, then select the data range you wish to analyze. Ensure the
data is organized with columns and headers.
Step 2: Go to the Insert tab
Go to the “Insert” tab and click on “PivotTable.” Excel will prompt you to choose
where the pivot table will appear.
Step 3: In the Tables group, click on the Pivot table tool
Step 5: Set Up Your Pivot Table
Excel will create an empty pivot sheet in Excel. Use the right-side panel to drag
fields (column headers) into rows, columns, and values.
How to Use Pivot Table Field Settings and Value Field
Setting:
Pivot table is one of the most powerful tools of Excel. It allows you to quickly
summarize a large chunk of organized data. But sometimes the values and fields
pivot table created by default is not really required. By default, Excel Pivot table
shows sum of numbers if you drag a number column to the value field. You may
not want the sum but average, or min, or max, etc… In that case you would need to
access pivot value field settings.
Step 1:
You can also right click on a Row Label and select Field Settings.
Or while having a row label selected, you can go to PivotTable Tools > Analyze >
Active Field > Field Settings
And now you have your Field Settings open.
Step 2: Now let us see how to access the Value Field Settings.
It has sales data by Date, Stores, and Regions (East, West, North, and South).
The dataset shown above have dates for two years (2014 and 2015).
Go to Pivot Table Tools –> Analyze –> Group –> Group Selection.
While grouping dates, you can select more than one options. By default,
Months option is already selected. You can select additional option along with
Month. To deselect Month, simply click on it.
It picks the ‘Starting at’ date and ‘Ending at’ date based on the source data. If
you want, you can change these.
Click OK
This summarization by years may be useful when you have more number of
years. In this case, it would be better to have the quarterly or monthly data.
In the above dataset, it makes more sense to drill down to quarters or months to
have a better understanding of the sales.
Go to Pivot Table Tools –> Analyze –> Group –> Group Selection.
In the Grouping dialogue box, select Quarters and deselect any other selected
option(s).
Click OK.
The issue with this pivot table is that it combines the Quarterly sales value for 2014
as well as 2015. Hence, for each quarter, the sales value is the sum of sales values
in Quarter 1 in 2014 and 2015.
In a real life scenario, you are most likely to analyze these quarters for each year
separately. To do this:
In the Grouping dialogue box, select Quarters as well as Years. You can
select more than one option by simply clicking on it.
Click OK.
This would summarize the data by Years and then within years by Quarters.
Something as shown below:
This would summarize the data by Years and then within years by Quarters.
Something as shown below:
When you group dates by more than one time-frame group, something interesting
happens. If you look at the field list, you will notice a new field has automatically
been added. In this case, it is Years.
Note that this new field that has appeared is not a part of the data source. This field
has been created in the Pivot Cache to quickly group and summarizes data. When
you ungroup the data, this field will vanish.
The benefit of having this new field is that now you can analyze the data with
quarters in rows and years in columns, as shown below:
All you need to do is drop the Year field from Row area to Columns area.
Grouping by Months in a Pivot Table:
Similar to the way we grouped the data by quarters, we can also do this by months.
Again, it is advisable to use both Year and Month to group the data instead of only
using months (unless you only have data for one or less than a year).
Go to Pivot Table Tools –> Analyze –> Group –> Group Selection.
In the Grouping dialogue box, select Months as well as Years. You can
select more than one option by simply clicking on it.
Click OK.
This would group the date field and summarize the data as shown below:
Again, this would lead to a new field of Years getting added to the PivotTable
fields. You can simply drag the years’ field to the columns area to get the years in
columns and months is rows. You will get something as shown below:
While analyzing data such as store sales or website traffic, it makes sense
to analyze it on a weekly basis.
When working with dates in Pivot Tables, grouping dates by week is a bit different
than grouping by months, quarters, or years.
Go to Pivot Table Tools –> Analyze –> Group –> Group Selection.
In the Grouping dialogue box, select Days and deselect any other selected
option(s). As soon as you do this, you would notice that the Number of Days
option (at the bottom right) becomes available.
Note that for this to work, you need to select Days option only.
In Number of days, enter 7 (or use the spin button to make the change).
If you click OK at this point, your data would be grouped by weeks starting
with January 4, 2014 – which is a Saturday. So the grouping would be from
Saturday to Friday every week. To change this grouping and to begin the
week from Monday, you need to change the start date (by default it picks the
start date from the source data).
In such a case, you can either start the date on December 30, 2013, or
January 6, 2014 (both Mondays).
Click OK.
This will group the dates by weeks as shown below:
Similarly, you can group dates by specifying any other number of days. For
example, instead of weekly, you can group dates in a biweekly interval.
Note:
When you group dates by using this method, you can not group it using any
other option (such as months, quarters or years).
Calculated field/item would not work when you group using Days
If you working with high volumes of data (such as call center data), you may want
to group it by seconds or minutes or hours.
Calculated Fields and Calculated Items in Excel Pivot Tables allow you to add
custom calculations to your Pivot Table without modifying the original data
source. Here's a breakdown of what each is, how to use them, and some example
scenarios.
A Calculated Field is a new field added to the Pivot Table that uses a formula to
calculate values based on other fields in the data source.
Use a Calculated Field when you want to create a new metric that’s derived from
existing fields. For example:
Click anywhere in your Pivot Table to activate the PivotTable Analyze (or
Options) tab.
Go to PivotTable Analyze > Fields, Items & Sets > Calculated Field.
In the Formula box, enter your formula. You can select fields to add by double-
clicking them in the Fields box.
For example, to calculate Profit as = Sales - Cost, type that formula in the Formula
box.
Result: The calculated field now appears in the Values area of your Pivot Table,
showing results based on the formula.
Let’s say your dataset has Sales and Cost fields, and you want to calculate Profit:
Your Pivot Table now shows Profit alongside other values, with values calculated
for each row.
Compare data within the same field, such as calculating a Total or Difference for
specific items.
Go to PivotTable Analyze > Fields, Items & Sets > Calculated Item.
Enter a name for the calculated item (e.g., "Total Q1 and Q2").
In the Formula box, create your formula by referencing other items within the
same field. You can add items by double-clicking them in the Items box.
Result: The new Calculated Item appears as a row or column in the Pivot Table,
showing the result based on your formula.
Suppose you have Quarter as a field and you want to create a column for the total
of Q1 and Q2:
The Pivot Table now displays a "Total Q1 and Q2" item in the Quarter field,
showing the combined values for each row.
Works on Entire fields in the data source Individual items within a field
Formula
Other fields in the Pivot Table Items within the same field
references
Tips
Calculated Fields apply across the entire Pivot Table, affecting all rows or
columns in the table.
Calculated Items only impact the specific field items and can make your Pivot
Table more complex if used extensively.
Be cautious with Calculated Items in large datasets, as they may slow down
performance due to the additional calculations.
Excel Pivot Tables themselves don’t directly support array functions within their
fields. However, array functions can still be used outside the Pivot Table to
perform advanced calculations or dynamic aggregations based on Pivot Table data.
Starting with Excel 365 and Excel 2019, dynamic array functions (like FILTER,
UNIQUE, SORT, etc.) offer more powerful ways to work alongside Pivot Tables.
Here’s how to integrate array functions effectively with Pivot Table data.
Suppose you have a Pivot Table that summarizes sales data by product and region,
and you want to extract rows from the original data that meet certain criteria based
on the Pivot Table.
Steps:
Use the FILTER function to extract rows that match criteria from the Pivot Table.
Example formula:
This will return all rows from your SalesData range where the Region is "North."
Result: You can use this extracted data for further analysis or for creating charts
based on the filtered Pivot Table data.
If your Pivot Table lists products, you might want to extract a list of unique
products without duplications.
Steps:
Select a cell outside the Pivot Table where you want the unique list to appear.
Use the UNIQUE function to generate unique values based on a column in the
Pivot Table:
1. =UNIQUE(PivotTableRange[Product])
2.
Result: This will create a dynamic list of unique products, which updates automatically when the
Pivot Table changes.
Example:
If your Pivot Table has sales by region and product, you can calculate the total
sales for a specific product across all regions using SUMIF.
=SUMPRODUCT((PivotTableRange[Product]="ProductA") *
(PivotTableRange[Region]="North") * PivotTableRange[Sales])
Dynamic Updates: When the Pivot Table data changes, array function results also
update automatically.
Excel Pivot Tables themselves don't support array formulas within their fields
directly. However, you can leverage array formulas alongside Pivot Tables to
create powerful, dynamic calculations that enhance your data analysis. This
approach is particularly useful in Excel 365 and Excel 2019 with dynamic array
functions like FILTER, UNIQUE, SORT, SEQUENCE, and others.Here’s how
you can use array formulas in conjunction with Pivot Tables:
1. Use Array Formulas Outside the Pivot Table for Advanced Analysis:
Although you can’t enter array formulas directly within the Pivot Table’s Values
area, you can use them outside the Pivot Table to reference its data and perform
advanced calculations. Here are a few scenarios where this is beneficial.
Suppose you have a Pivot Table showing sales by product and region, and you
want to extract rows from the original data that meet certain criteria based on the
Pivot Table summary. For instance, you might want all rows where the sales
exceed a specific amount.
Steps:
Select a cell outside the Pivot Table where you want the filtered data to appear.
Use the FILTER function to extract rows that match your criteria. For example:
=FILTER(SalesData, SalesData[Sales] > 1000, "No Data")
This formula will display only rows from the SalesData range where the sales exceed 1,000.
Result: A dynamic list of rows that updates automatically based on changes in the Pivot Table
and the specified criteria.
If your Pivot Table lists product names, you may want a list of unique products.
The UNIQUE function allows you to extract distinct values directly from the Pivot
Table data.
Steps:
Identify the range of the field (column) you want unique values for in the Pivot
Table (e.g., "Product").
Use the UNIQUE function outside the Pivot Table to generate a unique list based
on that field:
=UNIQUE(PivotTableRange[Product])
Result: A dynamic list of unique product names that updates when new products
are added to the Pivot Table data.
Suppose your Pivot Table has sales data by product and region, and you want to
calculate the total sales for a specific product and region combination, such as
Product A in the North region.
Steps:
Result: You’ll get a total that meets your criteria, updating automatically when the
Pivot Table or source data changes.
Dynamic arrays allow you to create dynamic reports or charts based on Pivot
Table data without manually refreshing ranges or restructuring data. You can build
out reports that adjust as Pivot Table results change, making reporting and
visualization more seamless.
For instance, you could create a dynamic chart showing the top 5 products by sales
using a SORT and INDEX combination:
This formula will return the top 5 products, sorted by sales in descending order,
ready for charting.
Dynamic Analysis: Array formulas are responsive to changes in Pivot Table data,
which is helpful when working with frequently updated data.
Enhanced Reporting and Filtering: Array formulas let you build customized
reports, create filtered views, and sort data dynamically based on Pivot Table
results.
Creating charts (like Bar Charts and Pie Charts) from a Pivot Table in Excel
provides a dynamic way to visualize and analyze your data. These charts
automatically update whenever the Pivot Table data changes, making them highly
useful for reports and dashboards.
Here’s how to create Bar Charts and Pie Charts from a Pivot Table:
Suppose you have a dataset with Product, Region, and Sales columns.
Drag Product into the Rows area and Sales into the Values area of the Pivot
Table.
In the Insert Chart dialog box, choose Bar Chart (either Clustered Bar or
Stacked Bar, depending on your preference) and click OK.
Use the Chart Design and Format tabs to customize colors, labels, and layout.
Right-click elements like axes or data labels to further refine the appearance.
Result: You’ll get a dynamic Bar Chart that updates automatically as you change
or filter your Pivot Table.
Example Scenario
If your Pivot Table summarizes total sales by product, a bar chart will display each
product as a separate bar, with the length of the bar indicating the sales amount.
This provides an immediate visual comparison of sales across products.
Set up your Pivot Table so it summarizes data in a way suitable for a pie chart,
such as Sales by Product or Sales by Region (only single-value field).
Drag Product (or your chosen category) into the Rows area and Sales into the
Values area.
In the Insert Chart dialog box, select Pie Chart and click OK.
Right-click on the Pie Chart to add Data Labels, showing percentages or values
for each slice.
Result: The Pie Chart will show each category (e.g., Product) as a slice,
representing its proportion relative to the total sales.
Example Scenario
If your Pivot Table shows sales by region, the Pie Chart will display each region as
a slice, showing its percentage share of total sales. This is especially useful for
presenting distribution or share of total values.
Dynamic Filtering: Filters applied to the Pivot Table also apply to the Pivot Chart.
You can filter directly in the Pivot Table or use the Chart Filters button to adjust
the data shown.
Data Refresh: Both the Pivot Table and Pivot Chart update automatically when
you refresh the data source or make changes in the underlying dataset.
Customize the Legend and Labels: Use the Chart Elements options to add or
modify legends, axis labels, and data labels for better clarity.
One Data Series Only: Pie charts work best with one data series, so avoid using
them when comparing multiple categories or fields.
Limited Categories: Pie charts become harder to read with more than five or six
slices; bar charts or other visualizations are preferable for complex data.
Creating a dashboard with Pivot Tables and Pivot Charts in Excel allows you to
present data in a clear, interactive, and visually appealing format. By combining
Pivot Tables, Pivot Charts, and additional slicers, you can create a dynamic
dashboard that updates automatically as your data changes. Here’s how to set up a
dashboard in Excel with tables and charts from Pivot Tables.
Organize Your Data: Ensure your data is in a clean, tabular format with column
headers, as Pivot Tables rely on a structured dataset.
Create a Data Table: Select your data and go to Insert > Table. This makes it
easier to add new data while keeping your Pivot Tables and charts updated.
For each analysis you want on the dashboard (e.g., Sales by Region, Sales by
Product), create a separate Pivot Table.
Go to Insert > Pivot Table, select your data source, and place the Pivot Table on a
new or existing worksheet.
Adjust the Pivot Table format by showing only relevant fields for clarity. For
example, you might want to display Total Sales by Month in one table and Sales
by Product in another.
Click on any cell within a Pivot Table, go to PivotTable Analyze > PivotChart,
and choose a chart type (e.g., Column, Bar, Line, or Pie).
Position the chart near its corresponding Pivot Table on the dashboard sheet.
Repeat this for each Pivot Table to create separate charts for each data view.
Use the Chart Design and Format tabs to adjust colors, styles, data labels, and
chart titles.
Keep your charts simple and consistent for a more professional look. For example,
you might use the same color scheme across all charts.
Insert Slicers:
Choose the fields you want users to filter by (e.g., Region, Product, or Sales Rep).
Position the slicers in a clear area on your dashboard (e.g., along the top or side).
If you have a date field in your Pivot Table, go to PivotTable Analyze > Insert
Timeline.
Select the date field to add a Timeline, allowing users to filter data by date ranges
like months, quarters, or years.
This ensures all charts and tables update simultaneously based on the selected
filter.
Use shapes, lines, or text boxes (found under Insert > Shapes/Text Box) to add
headings, labels, and section dividers to make your dashboard easier to read.
Turn off gridlines on the dashboard sheet (go to View > Gridlines) for a cleaner
look.
Adjust font sizes, styles, and colors for consistency across tables, charts, and
slicers.
Insert a text box or shape at the top of your dashboard with a title (e.g., “Sales
Dashboard”) to give it a polished, finished appearance.
Center Panel: Main Pivot Tables and Charts (e.g., Total Sales by Product, Sales
by Region).
Right Panel: Supplementary Metrics or Additional Pivot Charts (e.g., Sales Trends
Over Time).
This layout keeps filters accessible while displaying the most important charts and
tables centrally.
When you add new data to the source, simply refresh the Pivot Tables by clicking
any Pivot Table, going to PivotTable Analyze > Refresh, or right-clicking and
selecting Refresh. All Pivot Tables, charts, and filters on the dashboard will update
accordingly.
Keep it Simple: Avoid clutter by limiting the number of charts and tables. Focus
on the key insights.
Consistent Design: Use a uniform color scheme, font, and chart style for a
polished look.
Limit Pie Charts: Pie charts are best for showing simple parts of a whole; use bar
or column charts for more detailed comparisons.