Pivot Table Tutorial
Pivot Table Tutorial
2. Questions
Common questions by businesses looking to increase sales are given below. Analysis carried out
to answers them is also mentioned:
❖ Question # 1: Which countries have the highest Average Order Value (AOV)?
❖ Analysis: Aggregating data and calculating AOV for each country identifies countries with
higher sales and helps target marketing efforts to them to maximize revenue.
❖ Question: Which cities have the highest Average Order Value (AOV)?
❖ Analysis: Summarizing data and calculating AOV for each city identifies cities with higher
revenues and focuses advertising and promotions to them to increase sales.
❖ Question: Do new or returning customers have a higher Average Order Value (AOV)?
❖ Analysis: Segregating data into new and returning customers and calculating AOV for each
group helps explain which customer type spends more. This allows for tailored marketing
strategies to retain existing customers and attract new ones.
❖ Question: What is the revenue trend throughout the year, and how does it relate to the
Average Order Value (AOV)?
We use PivotTables to analyze the data on different dimensions - country, city, customer type,
and months to provide valuable insights into customer behavior and revenue patterns. Data-
driven decisions are used to optimize sales strategies, improve customer experience, and
ultimately increase sales.
3. Dataset
The dataset represents 11 years’ worth of online sales and includes the following columns:
❖ Serial: A unique identifier for each record in the dataset in ascending order.
❖ Txn_ID: A unique identifier to track and reference individual transactions.
❖ Revenue: Sales amount generated from each transaction.
❖ Country: Country where the order was placed.
❖ City: City where the order was placed.
❖ Year: Transaction year.
❖ Month: The month when the transaction was made.
❖ User_Type: Categorization of users into New Visitors and Returning Visitors.
❖ Device: The device used by the user to make a transaction - desktop, mobile or tablet.
❖ Source: The channel from which the user was acquired or reached the platform, e.g.,
organic search, direct search, referral.
❖ DaysToTxn: Number of days from the user's initial engagement with the site to sale.
Figure 1 shows a sample of the dataset. The full dataset is given on the tab “Master” in the
EXCEL worksheet “IBA-ITC-Raw-Dataset-FTC”.
4. Goal
The purpose is to convert the data to PivotTables, conditionally formatted tables, and graphs
to discern patterns and enable analysis.
To create a PivotTable go to the “Master” tab in the EXCEL worksheet. Select all the columns
and rows of the dataset. Click on the Insert tab in the main menu ribbon of the worksheet.
In the pop-up screen select the “Select a table or range” radio button. The selected data range
will appear in the input field “Table/Range:”. Choose the “New worksheet” radio button option
and click OK to create the PivotTable in a new tab.
Figure 6 – Create PivotTable pop-up showing the data source and output options
The field list contains the selected column names (or fields) from the dataset with check boxes
against them. Desired fields, based on the analysis to be performed, are dragged to one of four
areas - Filters, Columns, Rows or Values - to populate the PivotTable.
❖ Rows & columns – group the data by distinct categories in the selected fields
❖ Values – summarize the data from a selected field by a value type (such as sum or count
or average, etc.)
❖ Filters – allow for viewing subsets of the data or excluding certain data.
Various options and selections help in analyzing the data in different ways. Some variations are
discussed below.
❖ “Which top seven revenue-generating countries should sales effort be focused on?”
❖ “Which countries have a disproportionate share of sales, given their population, size, and
economic footprint?”
What fields do we need for the analysis? Country, year, revenue, and device (for order count).
Select and drag the “Country” field to the Rows area, “Revenue” and “Device” to the Values
area, and “Year” and “Revenue” to the Filters area of the PivotTable Fields list. No field is
entered in the Columns area. Columns in the PivotTable, therefore, will show the aggregated
Values area fields.
Revenue and device fields are added in the Values area. Specifically, we need the sum of
revenue and the number or count of devices (representing the number of orders) here. Click
the drop-down arrow against the field in the Values area, and select the Value Field Settings
option.
Choose how to summarize the data from the selected field by the type of calculation. You may
also choose to show the data other than as is. For example, the Sum of Revenue may be
expressed as a percentage of the total, a difference, a rank value, or index.
Our focus is the top seven revenue-generating countries. To order the display, click on the
dropdown button next to the column “Row Labels”. In the input field “Sort by” choose “Sum of
Revenue” and sort by Descending. Click OK.
Finally, to format the PivotTable and the copy-pasted table extract go to the Number
formatting section in the Home tab of the main menu ribbon. Click on the separator (comma)
and decimal formatting buttons as required.
❖ Rows: City
❖ Columns: [None]
❖ Values: Revenue (Sum), Serial (Count)
❖ Filters: Year, Revenue
The resulting table is ordered in descending order by Sum of Revenue with the highest revenue
generating cities appearing at the top of the table.
A variation of the PivotTable analysis by country, the table fields are the same (with Serial
instead of Devices used for the count of orders) with one exception. “User-Type” is added to
the Columns area of the PivotTable field list. Specifically, the fields are:
❖ Rows: County
❖ Columns: User_Type
❖ Values: Revenue (Sum), Serial (Count)
❖ Filters: Year (All), Revenue (exclude null or blank values)
Adding User_Type to the Columns area, segregates Revenue and Orders by New and Returning
Visitor. Total Sum of Revenue and Count of Serial columns show the totals across all customers.
We order the table by highest to lowest revenue-generating countries to run additional analysis
on the top N countries.
Figure 20 – Extract from the PivotTable of the top revenue-generating countries segmented for new and returning customers
Percentage share of new customers = Number of orders by new customers divided by the
number of orders across all customers.
Figure 21 - Calculating AOV and proportion of orders by country and customer segment
For example, returning customers from India have a higher proportion of orders and AOV
compared to new customers. For Saudi Arabia, new customers have a larger AOV.
a. Revenue by Year
The fields used are as follows:
❖ Rows: Year
❖ Columns: [None]
❖ Values: Revenue (Sum)
❖ Filter: Month (All)
Copy and paste this data to a separate table. To see a visual representation of this year-wise
data select the table. Go to the Insert tab and select the line graph chart to analyze trends over
time.
Use Formatting options to add features to the graph. For example, right clicking on the line and
selecting “Add Data Labels” will show the yearly revenue values at each point on the graph.
The graph shows that 2021 had the highest sales revenue. Since then, sales have declined.
b. Revenue by Month/Year
Next, we analyze the data by month as well as year.
Copy and paste this table to another area in the EXCEL sheet.
Use EXCEL’s AVERAGE() function to calculate the average monthly sales revenue for each
month across all years.
Highlight trends in the data, for example good and bad performing months, by applying
conditional formatting.
Select the table values to format. Go to the Home tab. Select the dropdown in the Conditional
formatting section. Go to the Color Scale options. Select the Green-Yellow-Red color scale
option.
A color gradient is applied to the cells with the maximum value cell green and minimum value
cell red. The gradient indicates where each value lies in the scale.
For February 2013, month on month change is revenue in February 2013 divided by revenue in
January 2013 -1. Copy and paste the formula to all cells in the table, except the cells in the
January column.
Given how the source table is constructed in EXCEL, the formula for January needs to be
different. The denominator should refer to the month of December of the previous year. Note
that December is the last column in the table, while the previous year is the immediately
preceding row. Hence the formula for the month of January is:
Show changes as percentages by right clicking on the cells. Go to Format Cells, choose category
Percentage and set Decimal places to 0%.
.
c. Graphical representation
To visualize the month/ year revenue, let us revisit the year on year change in Mmonthly
revenue table. Select the table. Go to the Insert tab. In the Charts sections click on waterfall
graph dropdown. Select 3-D surface.
Figure 40 – 3D surface chart for change in monthly revenue for a given year to average monthly revenue across all years
6. References
❖ The I in BI… - Jawwad Ahmed Farid – May 2023, https://risktrainer.medium.com/the-i-
in-bi-7399af34113d#ad4f
❖ Sizing market – Jawwad Ahmed Farid – Mar 2023,
https://risktrainer.medium.com/sizing-markets-5582ef58484b
❖ Tracking Growth – Jawwad Ahmed Farid – Jun 2023,
https://risktrainer.medium.com/sizing-markets-5582ef58484b
❖ Better Excel Charts, Jawwad Ahmed Farid, 2016
Data Analysis - Process of inspecting, cleaning, transforming, and modeling data to uncover
useful information, draw conclusions, and support decision-making.
Excel Template - A pre-designed spreadsheet in Microsoft Excel that can be used as a starting
point for various tasks or calculations.
Filter - A function used to selectively display specific data or elements based on certain criteria
or conditions.
Line Graph – A type of chart that displays data as points connected by straight lines, used to
show trends or changes over time.
PivotTable - A data summarization tool in Excel that allows users to arrange, analyze, and
summarize data from a larger dataset into a more manageable and organized format.
Power BI - A business analytics service by Microsoft that provides interactive data visualization
and business intelligence capabilities.
Revenue - The total income generated from sales of goods, services, or other sources within a
given period.
Seasonal Trends - recurring patterns in data that follow specific timeframes, typically repeating
on a yearly or seasonal basis.
Transaction - An exchange of goods, services, or financial assets between two or more parties.
Trend Lines - Lines on a graph that depict the general direction or pattern of data points, often
used to identify trends or patterns over time.