Project

Mastering Pivot Tables in Excel

A comprehensive learning program designed to equip learners with all necessary skills to effectively use pivot tables in Excel.

Empty image or helper icon

Mastering Pivot Tables in Excel

Description

The project starts with introducing Excel and pivot tables basics before gradually advancing to more complex functionalities. Learners will get both theoretical knowledge and hands-on experience through a series of practical exercises. The project will not only explain how to create a pivot table but also demonstrate its advantage in large scale data manipulation, and the accuracy and effectiveness it can offer.

Unit 1: Introduction to Excel and Pivot Tables Implementation Guide

Section I: Excel Setup

Assumes you have Microsoft Excel installed on your computer. If not, you will need to either purchase or subscribe to Office 365 to get the current version of Excel.

  1. Unlock Excel: Open Excel by navigating to your applications or using the search function in your operating system to find and open Excel.

  2. New Workbook: Once Excel is open, start with a new blank workbook from the default start-up screen.

  3. Worksheet Navigation: Familiarize yourself with the layout. Worksheets tab at the bottom, rows numbered and columns lettered, the formula bar at the top displays content of the currently selected cell.

  4. Input dummy data: For the purpose of this example, let's create dummy data with the columns "Month", "Sales Person", "Sales Unit", "Profits". Populate these with appropriate data values.

Months:[ "Jan", "Feb", "Mar", "Apr"]
Sales Person:["Jo", "Ann", "Mel", "Lee"]
Sales Units: [10, 15, 8, 13, 14, 9, 11, 10]
Profits: [500, 700, 600, 900, 650, 750, 560, 720]

3 spaces in each bracket represent a single instance in a row. Like: Jan, Jo, 10, 500 are all one row. Save and name your workbook as "Sales Data.xlsx".

Section II: Pivot Tables Setup

Pivot tables are incredibly useful tools for any data manipulation need in Excel. Here's how you create one using the prepared dummy data.

  1. Select Data Source: You first have to select a range of data to analyze. Highlight all of your data, headers included.

  2. Initiating Pivot Table: Navigate to the "Insert" tab in the Ribbon at the top of Excel, then select "PivotTable" in the Toolbar.

  3. Create Pivot Table: You will get a pop-up box. Here, your previous selection for the data is already in the range. The next decision you have to make is where you want the PivotTable report to be placed. You can either place it in a new worksheet or an existing one. Choose what suits you best. Click OK.

Section III: Manipulating Pivot Tables

After you clicked OK, you should be seeing an empty PivotTable and Field List Page with your data headers.

  1. Configure fields: Simply drag 'Months' into Rows area, 'Sales Person' into Columns area, and both 'Sales Units' and 'Profits' into Values area.

By default, Excel summarizes your data by either summing or counting the items.

  1. Value field settings: If you wish, you can change how to calculate the values (from sum to count, average, min, max, etc.) by clicking the dropdown arrow next to the value you're interested in changing and select "Value Field Settings". Then select the calculation you wish to use.

You can now easily see your data organized and summarized in a neat table grouped by columns you specified!

This concludes this implementation of Unit 1: Introduction to Excel and Pivot Tables. You can now use this basic knowledge to dig deeper into the functionality of Excel Pivot Tables: adding additional field calculations, applying filters, and much more.

Unit 2: Steps to Creating a Basic Pivot Table

As a continuation from Unit 1 where we introduced Excel and Pivot Tables, in this unit, we'll be focusing on steps to create a basic pivot table.

Step 1: Select Data

The first step in creating pivot tables is selecting the data that you want to use.

1. Open the Excel spreadsheet that contains the data you want to analyze.
2. Click the cell at the top-left corner of the data group you want to evaluate. 
3. Then, hold Shift and click the cell at the bottom-right corner of the data group.

Assuming that you have a data range comprising of 5 columns A to E, and 10 rows 1 to 10, you would click on A1, hold Shift, and then click on E10.

Step 2: Open the Pivot Table Creator

Now to open the pivot tables creator:

1. Click on `Insert` in the toolbar at the top of the screen.
2. In the drop-down menu, click on `PivotTable`.
3. This further opens a pop-up box.

This will launch the Create PivotTable dialog box in your spreadsheet, with your selected data already entered into the "Select a table or range" field.

Step 3: Create Pivot Table

In the pop-up box, I'm assuming that your range of data has headers, hence:

1. Make sure "Select a table or range" is chosen, and the range matches your selection.
2. Under "Choose where you want the PivotTable report to be placed", select "New Worksheet".
3. Click OK.

This creates a new worksheet with an empty pivot table and opens the "PivotTable Fields" tab on the right side of the screen.

Step 4: Choose Data For The Pivot Table

Now let's choose what data to include in the pivot table and how it should be displayed:

1. In the "PivotTable Fields" pane, under the list of fields, check the box for each field you want to include in your pivot table.
2. Drag and drop fields between "Filters", "Columns", "Rows", and "Values" areas depending on your requirement.

Let's say from your data, you are interested in the Sales details for each Product:

  • You'll drag Product to the Rows field.
  • And Sales to the Values field.

Now your basic pivot table, which shows the total Sales for each Product, is ready!

Remember, Excel doesn’t limit you to only rows and columns. You can also filter the data by any of the fields in the 'Filter' section.

This section gives the detailed steps for creating a basic pivot table. Advanced features or customizations, which allow for more complex data analyses, will be covered in subsequent units. Note that different versions of Excel might have slight differences in terms of menu labels and layouts.

Code For Google Sheets

For Google Sheets users, below is a step-by-step guide in Apps Script code equivalent to the process above. Using Apps Script allows you to create, access, and modify Google Sheets files.

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheets()[0];
var range = sheet.getRange("A1:E10");
var pivotTable = sheet.newPivotTable()
    .setSourceData(range)
    .addRowGroup("A") // replace "A" with the column header you want to group by.
    .addValue("E", SpreadsheetApp.PivotTableSummarizeFunction.SUM) // Adds total sales. Replace "E" with the column header you want to summarize.
    .setPosition(1, 1);

Please note that Google Sheets API must be enabled and properly set to use Apps Script.

Unit 3: Manipulating Data using Pivot Tables in Excel

In this unit, we will focus on various ways to manipulate data using Pivot tables. Let's consider you have a data set and you've already learnt from the previous units how to insert a basic Pivot table. Now, we will build on this knowledge and learn to manipulate data using Pivot Tables.

Task 1: Grouping Data

One of the most powerful features of Pivot Tables is their ability to group data. To implement this, follow the steps below:

  1. Group by Dates:

    1. Click on any cell which contains date.
    2. Go to Analyze Tab -> Group Selection.
    3. In the dialog box, select the appropriate time period (Months, Quarters, Years) and press OK.
    4. Your data will now be grouped by the chosen time period in the Pivot Table.
  2. Group by other fields:

    1. Right-click on any data point you want to group.
    2. Click on Group.
    3. In the Group By dialog box, specify the Start, End, and By values.
    4. Click OK. The selected values will be bucketed into the ranges you set.

Task 2: Creating Calculated Fields

Calculated fields are a way to create new data from data that already exists in your pivot table.

  1. Click anywhere in your Pivot Table.
  2. Go to the PivotTable Analyze tab and click on Fields, Items & Sets.
  3. Select Calculated Field.
  4. In the Name field, type a name for your calculated field.
  5. In the Formula field, create your formula. You can use Excel formulas normally, using fields from the Pivot Table by clicking the Insert Field button.
  6. Click Add to insert the field into your Pivot Table.

Task 3: Using Slicers for easy filtering

Slicers provides a very interactive way to filter your data.

  1. Click on your Pivot Table and go to the PivotTable Analyze tab.
  2. Click on Insert Slicer.
  3. In the Insert Slicers dialog box, tick the checkbox of the field (one or multiple) you want to create a slicer for.
  4. Click OK. Slicers will be added to your worksheet.
  5. To filter data, simply select the items you want to be displayed from the slicer.

Task 4: Using Pivot Charts

Pivot Charts provide a graphical representation of your data, making it easier to analyze.

  1. Click on your Pivot Table and go to the PivotTable Analyze tab.
  2. Click on the PivotChart command.
  3. In the Insert Chart dialog box, choose the chart type and click OK.
  4. A new Pivot Chart will be inserted on your current worksheet.

These are few ways you can manipulate data using Pivot Tables in Excel. Each of these tasks can be applied in numerous ways depending on your analysis needs. Once you understand these, you can start combining them to perform more complex data analysis tasks.

Implementation of Unit 4: Advanced Pivot Table Features

Assuming that you have a basic understanding of pivot tables and you've created a simple pivot table, let's move onto some more advanced features. This section will cover:

  • Grouping Fields
  • Adding a Calculated Field
  • Slicers

Data Set

Let's suppose we're working with a data set that contains information about the purchases made at a retail store:

| Order ID | Product | Category | Amount | Date | City |

Grouping Fields

Grouping helps in making better sense of data by categorizing it into different divisions. Excel allows users to group numeric as well as date fields.

Here is an example of how to group by Date (by month):

  1. First, create a simple pivot table with 'Date' in Rows area and 'Amount' in the Values area.
  2. Right-click on any date within the pivot table.
  3. Select 'Group'.
  4. In the Group by dialog box, select Months and click OK.

Excel will now display the total amount for each month, instead of each separate date.

Adding a Calculated Field

Calculated fields can be used when the data needed for analysis doesn’t exist in the raw data.

Here is how to add a Calculated Field:

  1. Select any cell in the pivot table.
  2. Go to Pivot Table Tools ➜ Analyze ➜ Calculations ➜ Fields, Items, & Sets ➜ Calculated Field.
  3. In the Name field, insert the name of the Calculated Field (in our case, we will use 'Average Order').
  4. In the Formula field, insert the formula for the Calculated Field. Our formula would be: =Amount / COUNT('Order ID').
  5. Click Add to insert the new field into the pivot table.

Our pivot table will now include an extra column, 'Average Order', that displays the average order value (Amount divided by the number of orders).

Slicers

Slicers are a visual way to filter the data in a pivot table. Unlike regular filters they provide a simple and intuitive way to filter data, providing buttons that you can click to filter the data.

Here is how to insert a Slicer:

  1. Click on any cell in the pivot table.
  2. Navigate to Pivot Table Tools ➜ Analyze ➜ Filter ➜ Insert Slicer.
  3. A dialog box will appear. Select the field(s) for which you want to create a Slicer. For example, 'City'.
  4. Click OK.

You will see a slicer box appear on the worksheet. You can click on a city (or multiple cities) and the Pivot Table will adjust to show only those cities you selected.

This sums up some of the advanced pivot table features.

Unit 5: Practical Application - Analysing Large Data Sets

In this section, we will deal with real-life scenarios of managing and analysing larger datasets which contains thousands of rows using Excel Pivot Tables.

Dataset

I will use an example dataset named SalesData.csv containing 10000 rows and the following columns: ORDERID, QUANTITYORDERED, PRICEEACH, ORDERLINENUMBER, SALES, ORDERDATE, STATUS, PRODUCTLINE, MSRP. This dataset is a typical example showing sales transactions data.

Loading the Data

For such big datasets, the recommended way to load the data into Excel is by using the Data Import feature in Excel.

  1. Open Excel.
  2. Go to the Data tab.
  3. In the Get & Transform Data section, click Get Data->From File->From Text/CSV.
  4. Choose the SalesData.csv file from your system and click Import.

Creating Pivot Tables

Follow the steps from 'Unit 2: Steps to Creating a Basic Pivot Table' to create a pivot table from the loaded dataset.

Analysis

Now, let's do some analysis on the dataset following the steps from 'Unit 3: Manipulating Data using Pivot Tables' and 'Unit 4: Advanced Pivot Table Features'.

Analysis 1: Yearly Sales

  1. Drag and drop ORDERDATE into rows and SALES into the values area.
  2. By default, the ORDERDATE will be grouped by Year, Quarter and Month. Right click on the year row -> Group-> deselect Quarter and Month.
  3. You will now see Total Sales for each Year.

Analysis 2: Yearly Sales by Product Line

  1. In addition to ORDERDATE and SALES, drag and drop PRODUCTLINE into the Rows area.
  2. Reorder PRODUCTLINE to appear before ORDERDATE.
  3. The Pivot Table would show you sales by product line, broken down by year.

Analysis 3: Top 5 Selling Products for Each Year.

  1. With ORDERDATE,PRODUCTLINE and SALES in the respective areas, drop ORDERID into the Values area.
  2. Click the drop down arrow next to Row Labels -> Value Filters -> Top 10.
  3. Change '10' to '5', click OK.
  4. Now, the pivot table shows the Top 5 selling products for each year.

Conclusion

Excel Pivot Tables are resourceful tools for quickly analyzing large datasets without having to write complex formulae or subsets of data. These practical examples illustrate how you can extract actionable insights from the piles of raw data available.

Unit 6: Debugging and Solving Common Issues with Pivot Tables

Section 1: Understanding the Issue

1.1: Pivot Table Won't Update

If your pivot table is not updating properly, it could be because it's not connected to the correct data source or the data source has not been refreshed. This problem usually arises when the data is being updated externally or more rows/columns are added.

' Solution:
Sub RefreshPivotTable()
    Sheets("YourSheetName").PivotTables("YourPivotTable").PivotCache.Refresh
End Sub

Make sure to replace "YourSheetName" and "YourPivotTable" with your specific sheet and pivot table names.

1.2: Incorrect or Incompatible Data Format

If your data fields are not appearing as expected (like dates appearing as integers), it's possible that Excel is reading the format incorrectly.

' Solution:
Sub ChangeFormat()
    Sheets("YourSheetName").PivotTables("YourPivotTable").PivotFields("YourField").NumberFormat = "YourFormat"
End Sub

Replace "YourSheetName", "YourPivotTable", "YourField", and format the data accordingly. Examples of formats could be "General", "mm/dd/yyyy" (for dates), etc.

Section 2: Fixing Errors

2.1: Error - "PivotTable field name already exists"

This error pops up when two or more columns have the same header.

Solution:

The solution requires manual intervention to change or update the duplicate header fields. It's not available via VBA.

2.2: Missing pivot table data

This issue arises when there's Blanks/Null values in the data.

' Solution:
Sub HandleBlanks()
    With Sheets("YourSheetName").PivotTables("YourPivotTable").PivotFields("YourField")
        .PivotItems("(blank)").Visible = False
    End With
End Sub

Replace "YourSheetName", "YourPivotTable" and "YourField" with your specific names.

Section 3: Performance Issues

3.1: Pivot Table Slowing Down Excel

A Pivot Table with a large data source might slow down Excel. One way to tackle this issue is by reducing the data source or turning off automatic updates and manually refreshing the Pivot Table.

' Solution:
Sub ManualUpdate()
    With Sheets("YourSheetName").PivotTables("YourPivotTable")
        .ManualUpdate = True
    End With
End Sub

Replace "YourSheetName" and "YourPivotTable" with your specific names.

Note: With this setting, don't forget to manually refresh the pivot table when needed as it won't update automatically.

This said, remember that debugging requires a deep understanding of both systems and data. Being familiar with common issues and practical ways to solve them will help streamline your data analysis process when working with Excel Pivot Tables.

Leveraging Pivot Charts for Data Visualization

Introduction

A pivot chart is a graphical representation of a data summary displayed in a pivot table. Pivot Charts offer a visual interpretation of data and provide a simple way to convey comparisons, patterns, and trends. Pivot charts and pivot tables always remain connected.

Steps to Creating a Pivot Chart

For creating a pivot chart in excel, we need to have an existing pivot table. Here we are assuming that an excel worksheet containing a pivot table is already open.

Here are the steps to create a pivot chart:

Step 1: Selecting the Pivot Table

  • Click anywhere in the Pivot Table.

This would automatically select the entire Pivot Table.

Step 2: Inserting Pivot Chart

  • Click on the Ribbon’s “Insert” tab.
  • Within the Charts group, click the Dialog Box Launcher (small corner arrow) next to PivotChart.
  • In the Insert Chart dialog box, choose the chart type and click OK.

This will insert a blank pivot chart. Excel also displays the PivotChart Tools tabs (comprising Analyze and Design) on the Ribbon.

Step 3: Formatting the Pivot Chart

  • Use the "Design" and "Format" tabs to modify the chart design and format.
  • To add, remove, or manage the data in the chart, use the "PivotChart Fields" window.

Please note that any change to the pivot table data will affect the pivot chart as well, since they are interconnected.

Example: Sales Data Visualization

Assume we have a pivot table with the monthly sales summary - units sold and total sales amount by product category.

The pivot table structure:

Row Labels Sum of Quantity Sum of Total Sales
Category 1 10 $700
Category 2 20 $1500
Category 3 15 $1200
Grand Total 45 $3400

Follow the steps mentioned above to create a pivot chart. Here we'll create a bar chart to visualize this sales data.

Implementation:

  • Click on any cell in the pivot table.
  • From the Ribbon’s “Insert” tab, click the Dialog Box Launcher next to PivotChart.
  • In the Insert Chart dialog box, select "Bar Chart" and click "OK".

This will create a bar chart for quantity and total sales by category. You can customize the chart - add chart title, change bar colours, adjust scale, etc., based on your needs.

Conclusion

The pivot chart provides a visual perspective of the pivot table data, making it much easier to draw insights and present it to others. Remember, any change to the source data or pivot table will automatically reflect in the pivot chart.

Final Project: Real-World Application of Pivot Tables

This guide will focus on a practical, real-world example of using Pivot Tables for data analysis. Based on the modules you've completed, we assume that you already have Excel installed, a dataset prepared, and know how to create, manipulate, and debug Pivot Tables.

Scenario

Assume that we're working with an e-commerce business's sales data. The dataset includes variables like Order ID, Date of purchase, Product category, Product name, Price, Quantity, and Sales. We will analyze the dataset to answer real-world business questions.

Loading the Data

First, import your data into Excel, and ensure that all columns are properly labeled with their respective data categories.

File => Open => Browse => Select your file

Creating a Pivot Table

  1. Go to the Insert tab and click on the PivotTable.
  2. For "Choose the data that you want to analyze", select "Select a table or range".
  3. Make sure that your range includes all data cells (excluding totals if they exist).
  4. For "Choose where you want the PivotTable report to be placed", select "New worksheet".
  5. Click on OK.
Insert => PivotTable => Select a table or range => New Worksheet => OK

With your PivotTable created, ensure that your data fields appear in the PivotTable Field List panel.

Data Analysis

Let's answer some business questions:

  1. What is the total revenue per product category?

    Drag 'Product category' to Rows and 'Sales' to Values.

    Drag 'Product category' to Rows
    Drag 'Sales' to Values

    Excel will automatically sum up the 'Sales' for each 'Product category'.

  2. What is the average price per product in each product category?

    Remove 'Sales' from Values and add 'Price' to Values. For 'Price' in Values, click on the dropdown, go to Value Field Settings, and choose Avg.

    Remove 'Sales' from Values
    Drag 'Price' to Values
    Value Field Settings => Avg

    This will give us the average price per product in each product category.

  3. What are the top 5 selling products overall based on quantity?

    Clear all current fields, add 'Product name' to Rows, and 'Quantity' to Values.

    Clear All Fields  
    Drag 'Product name' to Rows
    Drag 'Quantity' to Values

    Then, sort the Pivot table by 'Quantity’ in a descending order.

    Sort By => Quantity => Descending

    Finally, filter the Pivot table to show the top 5 rows.

    Filter => Top 10 AutoFilter => Top 5 Items
  4. What are the sales trend over time?

    For this, you can create a Pivot Chart as follows:

    Clear the fields, drag 'Date of purchase' to Rows, and 'Sales' to Values.

    Clear All Fields
    Drag 'Date of purchase' to Rows 
    Drag 'Sales' to Values

    Then, order the dates in ascending order:

    Sort By => Date of purchase => Ascending 

    Finally, create a Pivot Chart from the Pivot Table:

    Analyze Menu => PivotChart

    Choose Line Chart from the menu for a more clear presentation of sales trends.

This provides a practical real-world application of Pivot Tables in Excel, specifically for the purpose of conducting sales data analysis.